Your own while / else Help!


It reminded me "Something went wrong......", but I don't know and cannot find where the wrong place was.I wonder if the system is wrong.


And it reminded that a invalid syntax in line 9


what do you enter when you are prompted for input by raw_input?

Can you copy paste your code to the forum so i can run it?


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!"
    guesses_left -= 1
    print "You lose."




whatever you use after else, its not a colon. It looks like one, but it isn't. use a colon


Thank you so much, I was confused for a long time. I just messed the Chinese input method and the English input method up. It's so ignoring! Thanks a lot!


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