I have this code:
Words = ['python','candy', 'banana', 'chicken', 'pizza', 'calculus',
'cheeseburger', 'binder', 'computer', 'pencil', 'school'
'artist', 'soccer', 'tennis', 'basketball', 'panda',
'zebra', 'horse', 'cereal', 'alphabet', 'understand']
number = raw_input('Enter a 1 through 20: ')
x = list()
find = list(Words[int(number)-1])
notherword = list(Words[int(number)-1])
l = list(len(find)*'_')
print 'Your word is', len(find)*'_ '
playing = True
while playing:
letter = raw_input('Please pick a letter ')
if letter in find:
a = find.index(str(letter))
l[int(a)] = letter
q = (' ')
j = q.join(l)
print j
find[a] = ('_')
if l == notherword:
print 'You win!!!'
playing = False
else:
print 'Strike ' +str(len(x)+1) +str('.') +str(' Not a letter in the word')
x.append(letter)
if len(x) > 4:
print 'Game Over x('
playing = False
This is a hangman game. You first pick a number then that number corresponds with the word and starts a game of hangman. But when i do the word banana it only finds the first a and does not find the other a’s. How do I code so that it can find multiple instances at the same time so that it runs through fine??
Edited with newer code
You should replace this
with this