SyntaxError: invalid syntax



I am getting same error. Please help!

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("Enter your Guess: ")
    if guess == random_number:
        print "You win!"
    print"You lose."

File "python", line 10
if guess == random_number:
SyntaxError: invalid syntax

Your own while / else

The error is before the point indicated. That is where parsing stopped.

Check the brackets (parens) in the above.


Thanks, such a silliest mistake!

Code has resulted to infinite loop, will fix it now.


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