Error executing Python code.Am I doing something wrong or is it a problem in my IDLE?

Asked

Viewed 67 times

0

I’m a beginner in Python and just when I went to test the Turtle module for the first time it ran normally when I was typing the commands and running at each line. However, when I saved the same commands in a proper file and ran it, an error message appeared saying that the commands were not being recognized, even though I had imported the library and it worked in the previous method. Example:

from turtle import *
fd(100)
bye()

And then comes the message "Nameerror: name 'fd' is not defined", and I’ve tried different ways to write this same code and always have a similar error. Is this an IDLE feature or am I doing something wrong?

  • I know it’s a very silly question but surprisingly it occurs many times... you’ve seen if your program is running in the same directory that has a file. py called "Turtle" ? If so, the error is being caused because you are importing the Turtle module from this directory and not from the Python library.

  • When you print(Turtle) before calling the function fd(100) it is returning what exactly?

  • Jeanextreme002 - Yes...the file name was "Turtle",too,but now I changed and is working normally,that silly error...I would not have discovered alone, thank you very much and I’m sorry for the delay to reply.

  • Bart - Shows "Nameerror: name 'Turtle' is not defined",but anyway, now it’s working, thanks for your attention.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.