8. Your Own While/Else


#1



8. Your own While/Else


I'm getting the error:
File "python", line 9
if guess == random_number:
SyntaxError: invalid syntax


I'm not sure why I'm receiving this error, my code looks correct. Explanation?


from random import randint

# Generates a number from 1 through 10 inclusive
random_number = randint(1, 10)

guesses_left = 3
while guesses_left!=0:
    guess=int(raw_input("Guess: ")
    if guess == random_number:
        print "You win!"
        break
    guesses_left-=1
    else:
        print "You Lose"# Start your game!


#2

this line:

guess=int(raw_input("Guess: ")

the number of brackets (()) don't match


#3

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