8. I think my game works fine but it isn't being accepted *solved*



The game works as intended and includes an 'else' but I'm getting "Oops, try again. Did you include an else for the while loop?"

from random import randint

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

# Start your game!
print "Guess the golden number for amazing prizes!"
while guesses_left > 0:
    guess = raw_input("What is your guess?")
    guesses_left = guesses_left -1
    if guess == random_number:
        print "You win!"
    elif guesses_left > 0: 
        print "Unlucky, try again"
        print 'You lose.'


The else should go after the while loop.


while myVar == True:
    print "The condition in the while loop was False."


Thanks, it works fine now


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