I added an open file to my previously working code and now it's not doing what is supposed to.
I tested and ran for loop on an open file to see if everything is working and it did. It printed me a single list of all the words inside the txt file.
my expectation is to check if the word is in the words_list and continue, but now what happens is, it will always print (word is not in the list), even if I type the word that is indeed in the list.
words_list = []
with open("generated one column words.txt", "r") as f:
reader = f.read()
words_list.append(reader)
def main():
used_words = []
while True:
word = input("Type 4 letter word: ")
if not word.isalpha():
print("Only letters are allowed!")
elif word not in words_list:
print("word is not in the list")
elif len(word) == 4 and word not in used_words:
used_words.append(word)
print("good job, try another word")
elif word in used_words:
print("word already exists")
elif len(word) != 4:
print("word is not 4 letters long")
game = main()