correct_answer = "Tushar"
hidden_answer = "------"
lives = 7
correct_answer = correct_answer.split()
hidden_answer = hidden_answer.split()
while lives > 0 :
guess = input("Please enter your guess \n")
if guess in correct_answer:
for characters in correct_answer:
if guess == characters:
position = correct_answer.index(characters)
hidden_answer[position] = guess
print(hidden_answer)
else:
print(hidden_answer)
lives = lives - 1
print(lives)
if lives == 1:
break
Why does in the above code my else condition is being executed even if correct answer contains my guess?
Aucun commentaire:
Enregistrer un commentaire