So i'm trying to make simple hangman game, but while testing i cant append words from txt file to list, so the program can draw the word. Here is the code:
import random
words = []
def wordsChoose(mode, words):
mode = str(mode)+'.txt'
for line in open(mode):
words = words.append(line.rstrip())
theword = random.choice(words)
return theword
wordsChoose('fruits', words)
i get the: 'AttributeError: 'NoneType' object has no attribute 'append''
maybe there is a better option to do this