(8/19) I checked the 9th line online and I can't find why it won't work


#1

from random import randint

Generates a number from 1 through 10 inclusive

random_number = randint(1, 10)
while guess_left > 0:
print "you need to guess the number"
print "you have d% guess left" % guess_left
answer = raw_input("What is your guess between 1 and 10?"
if 0 <= answer <= 10:
if answer == random_number:
print "You win!"
break
else:
print "Please try again"
guesses_left -= 1
else:
print "choose a valid answer"
else:
print "You lost the number was %d" % random_number
guesses_left = 3

when I try it in idle the problem seems to be the column at the and of the "if 0 <= answer <= 10:" but every if should end in a column so I don'T get it sorry..


#2

You miss a ")"
Also don't forget the int() so the input will be a int not a string


#3

This works.

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!'
        break
    guesses_left -= 1
else:
    print 'You lose.'