'simple turtle module code python 3.9.7 problem
I am testing out the turtle module and the commands are not working. I am on windows 10 and have downloaded python 3.9.7 Here is the code:
>>> import turtle
>>> t = turtle.pen()
>>> t.forward(50)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
t.forward(50)
AttributeError: 'dict' object has no attribute 'forward'
>>>
This code opens the second window with the turtle display but it doesn't move forward and displays an error. Does anyone know how I can fix this?
Solution 1:[1]
The correct syntax is:
import turtle
t = turtle.Turtle() # create a Turtle and assign it to the variable "t"
t.forward(50)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mozway |
