8/19 unintended repeat of prompt


Hello. I used the following code for part 8:

while guesses_left >=0:
  guess= int(raw_input("your guess:"))
  if guess==random_number:
    print "You win!"
    print "Try again"
  guesses_left -= 1
  print "You lose"

the console shows

your guess:2
Try again
your guess:Try again
your guess:1
Try again
your guess:Try again
You lose

May I know why my code prompted the “your guess: Try again” bits


Also noticed that I only got 2 input tries. And that I should’ve made guesses_left>0


The course passed the code I wrote, just in case it was needed to be known.


with this changes, i get:

your guess: 3
Try again
your guess: 2
Try again
your guess: 2
Try again
You lose

your guess and try again never appear on the same line.

Might be a glitch in the exercise, what if you try it here:



Works fine there. May I assume that my code wasn’t being faulty then?


yes, you may. In fact, i can assure you


Thank you for your time.


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