1

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?

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Kbeast
  • 57
  • 1
  • 7
  • This is a case error, it should be: `t = turtle.Pen()` the uppercase `Pen()` is an alias for `Turtle()` whereas the lowercase `pen()` function is something completely different. – cdlane Sep 25 '21 at 02:55

1 Answers1

0

The correct syntax is:

import turtle
t = turtle.Turtle() # create a Turtle and assign it to the variable "t"
t.forward(50)
mozway
  • 194,879
  • 13
  • 39
  • 75