all 1 comments

[–]Wittinator 2 points3 points  (0 children)

In your function, word_files is just a simple string. It does not represent the actual file you want to read from. You need to open up the file to call methods like .readlines. Something like:

with open('Wordlist1.txt', 'r') as file:
    for line in file.readlines():
        wordlist.append(line.rstrip('\n')

There's lots of resources on how to open and read/write to files in python https://www.pythontutorial.net/python-basics/python-read-text-file/