8. Your own while / else


#1

from random import randint

Generates a number from 1 through 10 inclusive

random_number = randint(1, 10)

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

what do I do to fix this mistake?
not too sure what to do now


#2

Your code is missing a few things that I will explain in comments so just read and ask if you still don't understand.


#3

Hey ! On line 8, you have written -
guess = int(raw_input('Your guess: ')
Thatswhy it is giving syntax error. You have to close the second bracket too.

Do this and re-run
guess = int(raw_input('Your guess: '))

Hope it helps !


#4

wow thank I got it to work


#5

You're welcome :slight_smile:


#7