An endless loop
bartc
bc at freeuk.com
Sun Oct 15 06:15:22 EDT 2017
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').
That looks to be a repeat-N-times loop. There isn't a dedicated
statement for that, the closest Python feature would be 'for i in
range(n)' with i a dummy loop variable.
--
bartc
More information about the Python-list
mailing list