I am having a very hard time with this section of loops. The instructions are; Use a while loop to let the user keep guessing so long as guesses_left is greater than zero.
Ask the user for their guess, just like the second example above.
If they guess correctly, print ‘You win!’ and break.
Decrement guesses_left by one.
Use an else: case after your while loop to print You lose.
And I am not sure what they are saying.
This is my code:
while guesses_left > 0: guess = int(raw_input("Your guess: ")) print guess if guess == random_number: print "You win!" break guess_left -= 1 else: print "You lose."
But it didn’t works. So if everyone can help, please help me.