An endless loop

Peter J. Holzer hjp-usenet3 at hjp.at
Sun Oct 15 06:23:30 EDT 2017


On 2017-10-15 10:15, bartc <bc at freeuk.com> wrote:
> On 15/10/2017 03:10, Stefan Ram wrote:
>>    I made an error I made a thousand times before.
>> 
>>    I had programmed an endless loop.
>> 
>>    But never did I see before so clear why it's called
>>    an endless loop. (Tested in IDLE.)
>> 
>> from turtle import *
>> 
>> reset(); reset(); shape( 'turtle' ); showturtle()
>> 
>> def poly( n, length ):
>>      i = 0
>>      while i < n:
>>          forward( length )
>>          left( 360/n )
>> 
>> poly( 5, 100 )
>> done()
>
> I assume you're talking about the while-loop (because on my machine, it 
> hangs just using 'from turtle...' or 'import turtle').

No graphics? 

For those of you who can't use turtle graphics and aren't familiar
enough with it to see what it does without running the program: It
displays a turtle running through the same (pentagon-shaped) loop over
and over again.

Yes, that's a very nice visualization of an endless loop.

        hp

-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp at hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel



More information about the Python-list mailing list