On 24/09/11 15:43, Cameron Macleod wrote:
Hi,

I've been trying to code a simple guess my number game as a starter
programming project but I've generated an infinite loop accidentally.
Since I'm new to programming in general, I can't really figure out
what's causing it.

Nehal told you how to fix it but didn't explain why.

You have the input() call indented to the same level as the else block so it only gets executed as part of that block. If the guessed number is greater than the target the loop repeats infinitely.

By moving the input() line out you get a new number each time.

HTH


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to