I've tried this a few different ways and I'm stuck.
- If I run this and guess the correct number the code ends giving me a "congratulations" dialog even though the code is wrong.
- If I guess the wrong number it ends as if I've put a break in it, again with a "congratulations" dialog.
- I can't get it to decrease the guess count. I've ran it in the labs space to check these. It is not helpful that the code is passed as correct when it isn't. This isn't the first time I've had this.
I've got a few commented lines in the code so I could make sure I entered the wrong number and so I could see the remaining guesses. I also put the break in since it kept looping and freezing my browser. Something else that bothers me is I don't know if I'm supposed to get 3 guesses in this exercise or not. This stuff needs to be more clear
from random import randint # Generates a number from 1 through 10 inclusive random_number = randint(1, 10) guesses_left = 3 print random_number # Start your game! guess = int(raw_input("Pick a number from 1 - 10:")) while guesses_left > 0: if guess == random_number: print "You win!" break else: #print "Guesses remaining " + str(guesses_left) guesses_left -= 1 guess #break else: print "You lose."