#8 while/else


#1



Please help me fix my error


The console runs the way I expected, but i get the error
Oops, try again. Did you include an else for the while loop?


# Generates a number from 1 through 10 inclusive
random_number = randint(1, 10)

guesses_left = 3
# Start your game!
print "guess my number 1- 10"
while guesses_left > 0:
    print "Guesses remaining", guesses_left
    guess = int(raw_input("Your guess:  "))
    if guess == random_number:
        print "You Win"
        break
    else:
        print " sorry"
        guesses_left  -= 1
    if guesses_left == 0:
        print "game over"


#2

The error message would indicate the lesson checker is looking for,

while ____:

    #code

else:
    print "You lose."

#3

Thank you for your help:smiley_cat:


#4

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