[solved]Your own while/else breaking for invalid syntax that looks okay to me?


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/8?curriculum_id=4f89dab3d788890003000096#


I am getting the error code for line 10 that there is incorrect sytnax. It looks okay to me and matches what others have on this question, so I must be missing something.

Also, I started by breaking the loop by adjusting the count to equal 4 in place of the break, but took that out. That seems like it should work instead of using a break, right?


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:
    guess = int(raw_input("Your guess: ")
    if guess == random_number:
        print "You win!"
        break
    guesses_left -= 1
    else:
        print "You lose."


#2

Gah. Dropped a parenthesis on line 10 and the else should have been aligned with the while loop. This worked:
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:
guess = int(raw_input("Your guess: "))
if guess == random_number:
print "You win!"
break
guesses_left -= 1
else:
print "You lose."


#3