secret_word = "apple"
guess = ""
guess_count = 0
guess_limit = 3
guess_finished = False
while guess != secret_word and not(guess_finished):
if guess_count < guess_limit:
guess = input("Enter a word: ")
guess_count = 1
else:`
guess_finished = True
if guess_finished:
print("You lose")
else:
print("you win!")
CodePudding user response:
You have an extra space at the beginning of line 2 and it goes til while condition. You can just remove all spaces and try again. This should work
secret_word = "apple"
guess = ""
guess_count = 0
guess_limit = 3
guess_finished = False
while guess != secret_word and not(guess_finished):
if guess_count < guess_limit:
guess = input("Enter a word: ")
guess_count = 1
else:
guess_finished = True
if guess_finished:
print("You lose")
else:
print("you win!")
CodePudding user response:
All the indents look normal to me, this looks like a syntax error. I think the ' ` ' char does not belong there after the 'else:' in line 19
Try this code, it works for me...
secret_word = "apple"
guess = ""
guess_count = 0
guess_limit = 3
guess_finished = False
while guess != secret_word and not(guess_finished):
if guess_count < guess_limit:
guess = input("Enter a word: ")
guess_count = 1
else:
guess_finished = True
if guess_finished:
print("You lose")
else:
print("you win!")
CodePudding user response:
This worked for me
secret_word = "apple"
guess = ""
guess_count = 0
guess_limit = 3
guess_finished = False
while guess != secret_word and not(guess_finished):
if guess_count < guess_limit:
guess = input("Enter a word: ")
guess_count = 1
else:
guess_finished = True
if guess_finished:
print("You lose")
else:
print("you win!")