Your own while/else


#1

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

File "python", line 9
while guesses_left > 0:
^
SyntaxError: invalid syntax

I am not sure what´s wrong with my syntax 0:)
Any tips? :slight_smile:

 
from random import randint



guesses_left = 3
random_number = randint(1,10)
guess = int(raw_input('Your guess: ')

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

look at the parantheses at the line above the error message


#3

guess = int(raw_input('Your guess: ')) * you missed one bracket


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.