8. Your own While/ Else


from random import randint

random_number = randint(1, 10)

guesses_left = 3

while guessesleft > 0:
guess = int(rawinput("Guess a # 1-9:"))
if guess == randomnumber:
print "You win!"

print "Try again:"
guessesleft -= 1
print "You lose."

I did indenting and I get this

File "python", line 13
SyntaxError: invalid syntax


Your variables need to be seperated by underscores. Example:

my_variable = "Cade"


THANKS SO MUCH! THAT Helped so much


Wait I just tried that and I got

File "python", line 13
SyntaxError: invalid syntax


I assume that your whitespace is wrong.


what is that? White space what is that?


It is how Python distinguishes functions. After a colon, you must have whitespace (Four spaces or tab). Example:

def print_cade():
    for num in range(1, 100):
        print "Cade"



NVM found out :slightly_smiling:
the answer


which one is it i am getting mad on this exercise


Sorry, but not going to give you a free answer. :slightly_smiling:


I'm not sure if you've had more help with this, but there needs to be an "if" statement in the code as shown in the example, this isn't very clear in the instructions, I suspect it's assumed that one will follow the screenshots verbatim in this one unlike many others in the course.