from ftplib import parse150 import os, sys def txthandler(path): f = open(path) print(f.read()) return 0 def pdfhandler(path): f = open(path) print(f.read()) return 0 def dochandler(path): f = open(path) print(f.read()) return 0 #Attempting to pass docx file in path path = 'C:/Users/a big fuck/Downloads/beans.docx' extension = path[path.rfind('.')+1: len(path)] print(extension) if extension =='txt': txthandler(path) elif extension == 'pdf': pdfhandler(path) elif extension == 'doc' or 'docx': dochandler(path) else: print("Extension not recognized") sys.exit()