No idea why it shows me that I don't close the loop


#1

Hi!

I have similar problem. I have no idea why it shows me that I don't close the loop. The "game" works fine and I can't see any drawbacks in the code. Can anybody have a look? It starts driving me crazy. Thank you!

from random import randint

Generates a number from 1 through 10 inclusive

random_number = randint(1, 10)
print random_number
guesses_left = 3

Start your game!

while guesses_left > 0:
guess = int(raw_input("Your guess is: "))
guesses_left -= 1
print "Guesses left: ", guesses_left
if guess == random_number:
print "You won"
break
else:
if guesses_left > 0:
print "Try again"
else:
print "You lost"
break


Your own while/else
#2

What do you mean by not closing a loop? How can others see the same thing?
What does your code really look like? Make sure the code is intact


#3

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