[Tutor] Loop Issue

Alan Gauld alan.gauld at btinternet.com
Wed Mar 12 10:18:05 CET 2014


On 11/03/14 13:53, Yanni Phone wrote:

> health = 10
> trolls = 0
> damage = 3
> while health != 0:
>     trolls += 1
>     health -= damage

> This seems simple enough. (This is an example of a non-terminating loop,
> by the way, so it is not suppose to work correctly.)

> My problem is that when I enter this into IDLE, and hot enter a few times.
 > I never get my prompt (>>>) back.

That's because, as you just said, its a non-terminating loop.
The prompt only returns when the loop ends, which is currently never.

You will need to interrupt the loop (using Ctrl-C?) and fix the bug.



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



More information about the Tutor mailing list