4/18 How is this a bad syntax?


#1

'''from random import randint
random_number = randint(1, 10)

guesses_left = 3

while guessesleft > 0:
guess = int(rawinput("Your guess: "))
if guess == randomnumber:
print "You Win!"
break
guessesleft -= 1
else:
print "You lose'''

The error message is: File "python", line 12
else:
^
SyntaxError: invalid syntax


#2

After if you have break which would ignore any if's and else's after it (If it reached that point) so when it reaches break it leaves the if operation then you add an else out of nowhere. Remove the break or change the else to if. Also that guessesleft -= 1 will never be reached.