Your own while/ else


#1

I think I completed this task however the system won´t mark it as completed and throws back the error message "make sure to decrement guesses_left"
why is that ?

My code is as follows:

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 !"
break
guesses_left += -1
else:
print "you loose!"


#2

guesses_left += -1 should be:

guesses_left -= 1

or

guesses_left = guesses_left - 1


#3

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