I'm trying to make a simple hangman game in Python 2.7.10. However when I try to append "_" for every letter in the word in a list. It throws:
Traceback (most recent call last):
File "C:\Users\Janek\Dropbox\python\vjesalo.py", line 82, in <module>
append.wordlen(olo)
NameError: name 'append' is not defined
No idea why this happends because if I run in the python terminal
list = []
list.append("Bla bla bla")
It works just fine
Here is my code:
from sys import exit
from time import sleep
word = raw_input("Enter a word: ")
if word.isalpha() == True:
word.lower()
else:
print "Invalid word!"
sleep(3)
exit()
wordlen = []
for i in range(len(word)):
append.wordlen("_")
print wordlen
You have the call backwards
append.wordlen("_")
You meant
wordlen.append("_")