Your own while / else (syntax error?)


For some reason, my code gives a syntax error on line 10. I have no idea how, it changes color (shows in bold here), has a variable and a condition, and an indent for the rest of the code. What am I missing?

I'm trying to get the loop to work, and I've even copy-pasted other functioning scrips in my own (of course after verifying that I've done it correctly), but it still says I'm doing something wrong.

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 my number... ")
    if guess == random_number:
        print "You win!"
    guesses_left -= 1
    print "You lose."


Missing a closing parenthesis for int().


... facepalm I'm a genius. Thanks for pointing that out! It's all good now.


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