Search code examples
pythonvisual-studio-codeturtle-graphicspython-turtle

Python Turtle Error In Visual Studio Code


So i made a python turtle thing a while ago and it worked just fine. However, when i try to run it now it doesnt work. Here is the code:

import turtle
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.right(144)
turtle.forward(100)
turtle.exitonclick()

It gives a error saying:

Exception has occurred: AttributeError module 'turtle' has no attribute 'forward' File "C:\Users\melek büyük\Desktop\Programlama\Python\ptrh.py", line 2, in turtle.forward(100)"

It didn't do this before. Can someone please help me?


Solution

  • Seems like your file might be called turtle or you have another file called turtle. This would cause the import to not actual import the turtle library, so you should rename the file.