On Sun, Oct 15, 2017 at 9:15 PM, bartc <b...@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'). > > 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.
You can use that or "for _ in range(n)" as a pretty effective form of that loop. I've never had a problem with it. Python doesn't need another type of loop. ChrisA -- https://mail.python.org/mailman/listinfo/python-list