[Tutor] Loop Issue

2014-03-12 Thread Yanni Phone
Hello all,

I was following along in a book called 'Python Programming for the Absolute
Beginner' by Michael Dawson and I ran into an odd problem with a loop.
Dawson has the following code in his book:

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. It just lets me hot enter a bunch of time as though it is
expecting more input from me. I tried making a similar loop and it gave me
my prompt back just fine.

Does anyone know what might be going on here?

Thanks,
Yanni
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Loop Issue

2014-03-13 Thread Yanni Phone
OK, thank you. I knew the loop was infinite but usuyally when I did
infinite loops before, I had them print out a message, so it was obvious.
Thanks for the clarification.


On Thu, Mar 13, 2014 at 9:38 AM, spir  wrote:

> On 03/13/2014 12:40 AM, Danny Yoo wrote:
>
>> The context is the beginning of the thread:
>>
>>  https://mail.python.org/pipermail/tutor/2014-March/100543.html
>>
>> with the loop:
>>
>>
>> ###
>> while health != 0:
>>  ...
>> ###
>>
>
> The point, and reason why this loop was (potentially) infinite, is that
> the condition was false. Should be <0 instead ('cause health points are not
> removed one by one, so that a health value of 0 exactly can be jumped over).
>
> d
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor