Your own while else


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/8?curriculum_id=4f89dab3d788890003000096


Oops, try again. Did you print the "You lose." message?


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
    elif guess != random_number:
        guesses_left = guesses_left-1
else:
    print "you loose"


#2

if i win i am moving ahead in the excercise, but if i don't guess right it is throwing an error even if i get a print out you loose


#3

you should print "You lose." (not loose)


#4

thank you... ! i spent more that 3 hours.. !!!! just for a o


#5

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