Hi guys! really stuck on this one so any help will be greatly appreciated!
I am basically confused about the logical flow behind what I type, so here it goes:
Error says: Did you print the "You win!" message?
No syntax error according to the programme.
I am expecting a correct response to trigger the "You win!" if statement below, but instead it triggers "You lose." else statement.
from random import randint # Generates a number from 1 through 10 inclusive random_number = randint(1, 10) print random_number guesses_left = 3 guess = int(raw_input("Your guess: ")) while guess != random_number and guesses_left > 0: guess = int(raw_input("Your guess is incorrect. Plase try again: ")) print "Guesses left: %s" % guesses_left if guess == random_number: print "You win!" break guesses_left -= 1 else: print "You lose."
What's wrong with my code? please help!
Thanks a bunch!