8. Your own while/else


#1

https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/8?curriculum_id=4f89dab3d788890003000096#
<In what way does your code behave incorrectly? Include ALL error messages.>
I don’t know what is wrong with my code, it throws me the following error message (see below). I checked everything in line 10, but I can’t figure out the error.

File “python”, line 10
if number == guess:
^
SyntaxError: invalid syntax

```python

from random import randint

Generates a number from 1 through 10 inclusive

number = random.randint(1, 10)

guesses_left = 3

Start your game!

while guesses_left > 0:
guess = int(raw_input("Your guess: ")
if number == guess:
print “You win!”
break
else:
print “You lose.”
guesses_left -= 1

<do not remove the three backticks above>

Indentation?
#2

this line:

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

missing bracket ()) at the end, to close your casting to int


#3

THANK YOU SO MUCH.

I can’t believe I’ve been stuck for hours because a bracket.


#4

Now it doesn’t recognize the else statement. :frowning:


#5

It’s solved. The “else” statement was bad indented. It was supossed to be at the same level that the “while” statement.