New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
step bug in turtle's for loop #87455
Comments
from turtle import *
col = ["black", "white"]
for rad in range(40, 0, -1):
dot(5*rad, col[rad % 2])
done() ====================== Thank you. |
Correction to my msg387472: Every *even* step crashes the code. |
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. |
Thank you Dennis for taking the time to answer. <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail\> On Mon, Feb 22, 2021 at 3:21 AM Dennis Sweeney <report@bugs.python.org>
|
Yehuda, one can also ask questions like this on python-list. In the future, when responding by email, please delete the message being responded to, so it does not get repeated when posted to the web page. |
Thank you Terry, and take care. Yehuda <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail\> On Sat, Feb 27, 2021 at 4:41 AM Terry J. Reedy <report@bugs.python.org>
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: