Hello. I am facing an issue with my python application. Apparently the variable I am using is not a list object, yet for some reason I get this error when the following code is executed:
def buildShow(): directory = "Used Words" if(os.path.exists(directory)): for files in os.walk(directory): for name in files: if name.startswith("2020"): file=open(os.path.join(directory,file),"r+") txt=file.read() file.close() lines=txt.split('\n') words= for line in lines: words.append(line.split('\n')) if e1.get() in words: tk.messagebox.showinfo("Warning", "World Already Used")
AttributeError: ‘list’ object has no attribute ‘startswith’
This is meant to look through all the .txt files in the “Used Words” directory, and scan each of them for a specific word (e1.get()).
Would really appreciate some help. Thanks.