8/19 Syntax Error


In my code, I typed:

if guess == random number:
print "You win!"

It gives me a syntax error. Here's all of my code:

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


Have you noticed the indentation of print "You win!"?


what do you mean. Shouldn't it be indented?


Em... Excuse my English.
I mean it should be indented with 4 spaces, not with a '\tab'.
Mixing blank space and '\tab' in one line is a common error, and using blank space only is a good habit.
Hope it will help.
Enjoy Python : )


It's still not working. It's just the if guess == random_number: part.


I think you lose ) in line 9


I know. I figured it out a while ago.


guess = int(raw_input("Your Guess: ")
look at this one more time, something's missing

guess = int(raw_input("Your Guess: "))


:grin::+1::sweat_smile: You may have not realized this but you said “I figured it out a while ago” :grin::+1::sweat_smile: