I entered the correct code, but an error appears and does not run. NameError: name 'speed' is not defined.

Asked 2 years ago, Updated 2 years ago, 120 views

When I ran it on my computer, that error didn't work. But when I moved it to my laptop and ran it, it worked normally. What's wrong with the computer's running environment that doesn't work?

python nameerror

2022-09-21 11:14

1 Answers

Python beginners make a lot of mistakes.

Clear or rename the turtle.py file on your desktop.

The reason for the error is

from turtle import *

The error NameError: name 'speed' is not defined occurs because the turtle package in the library is not imported in part, the turtle.py file is imported in the same location as the script, and speed is not defined in the turtle.py file.


2022-09-21 11:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.