Invalid Syntax for Print Statement


I'm stuck on exercise 14.8 - Your own while / else

The code looks right, but whenever I try to run it, in throws an invalid syntax error for line 11 (a print statement). In earlier exercises, codecademy was fine with the print statement instead of the function, so I used that. I tried the function too and it didn't work either.

from random import randint

random_number = randint(1, 10)

guesses_left = 3

while guesses_left > 0:
  guess = int(input("Your guess: ")
  if guess == random_number
    print "You win!"
  guesses_left -= 1
  print "You lose."


guess = int(input("Your guess: ")
You missed closing parentheses ) there.

if guess == random_number
You missed a colon : after if's condition.


Thanks! I learned Ruby first, so I have a habit of leaving off colons on if statements...but the parentheses was a dumb mistake.


I have a habit of leaving off colons

yeah,It happens
syntax mixups.
cheers! :slight_smile:


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