The_Bread_Coder
The_Bread_Coder

Reputation: 43

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?

Upvotes: 2

Views: 1069

Answers (2)

Mercury
Mercury

Reputation: 310

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.

Upvotes: 4

miistyyy
miistyyy

Reputation: 46

I guess you forgot to initialize a new object like this:

import turtle

your_turtle = turtle.Turtle()

# And then you can start drawing

your_turtle.forward(100)
your_turtle.right(144)
your_turtle.forward(100)
your_turtle.right(144)
your_turtle.forward(100)

# ...

Upvotes: -2

Related Questions