Apr-20-2019, 02:30 AM
i'm totally new to Python and I've been watching YouTube videos to get started with the language. In one of the videos, it showed us how to build a guessing game using while loops & if statements. I did the same, but it doesn't seem to work for me.
secret_word = "harry"
guess = ""
guess_count = 0
guess_limit = 3
out_of_guesses = False
while guess != secret_word and not(out_of_guesses):
if guess_count < guess_limit:
guess = input("Enter your guess: ")
guess_count += 1
else:
out_of_guesses = True
if out_of_guesses:
print("Out of guesses. Better luck next time!")
else:
print("Congrats! You win!")It gives me 3 tries, just like I specified. But when I type in the right word, it doesn't do anything. How do I fix this?
