[issue43289] step bug in turtle's for loop

Dennis Sweeney report at bugs.python.org
Sun Feb 21 20:21:52 EST 2021


Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:

If I understand correctly, changing the -1 to a -2 does not actually make the program "crash" -- you just only see one black circle.

The reason is that range(40, 0, -2) produces 40, 38, 36, etc., all of which are even numbers, so rad % 2 is always 0, so col[rad % 2] is always "black". You could try:

    for index, rad in enumerate(range(40, 0, -2)): 
        dot(5*rad, col[index % 2])

In the future, I would suggest asking questions like this on StackOverflow, since this is not a bug in Python itself.

----------
nosy: +Dennis Sweeney

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43289>
_______________________________________


More information about the Python-bugs-list mailing list