Jun-24-2018, 09:21 PM
I have been trying to make hangman but I have not been able to figure it out. I found a video and copied the code down so I could then figure out whats going on and then write my own version, but, the code does not work and I'm not sure what is happening. When I run it in BBEdit no matter what letter I put in, it just prints the underscores and The "guess a letter" part.
import random
possibleAnswers = ["dog","human","bed"]
random.shuffle(possibleAnswers)
answer = (possibleAnswers[1])
display = []
display.extend(answer)
for i in range(len(display)):
display[i] = ("_")
print(" ".join(display))
count = 0
while count < len(answer):
guess = input("Please guess a letter: ")
guess = guess.upper()
for i in range(len(answer)):
if answer[i] == guess:
display[i] = guess
count += 1
print(" ".join(display))
print("You guessed it!")
