Here is the error:
File "python", line 15
SyntaxError: invalid syntax
What do you expect to happen instead?
I expect the else statement to work perfectly fine. I don't understand why there is a syntax error. This is NOT required in the instructions but I wanted to incorporate what I've learned from other lessons. Any ideas? Thanks!
from random import randint # Generates a number from 1 through 10 inclusive random_number = randint(1, 10) guesses_left = 3 # Start your game! while guesses_left > 0: print "Please guess a number between 1 and 10: " guess = int(raw_input("Your guess: ")) if guess == random_number: print "Dang, you are good! That's correct!" break guesses_left -= 1 else: print "Nope, try again! You are within %s of the number!" % random_number - guess else: print "You lose."