Xneon666
Xneon666

Reputation: 1

Why is the turtle in python not working when I import it?

Here's my code

Import turtle

t = turtle.pen()

t.forward(50)

And this is the error I get

Traceback (most recent call last) :
File "<pyshell#4>", Line 1, in <module>
t.forward(50)
AttributeError: 'dict' object has no attribute 'forward' 

Upvotes: -1

Views: 857

Answers (2)

Ansan
Ansan

Reputation: 9

the right answer is to capitalize "P", in "pen"

Upvotes: -1

Turtle.pen is used to set/get pen attributes of turtle but not to draw(see help(turtle.pen) for more info), in order to draw something you need to get Turtle object as follow:

import turtle
tur=turtle.Turtle();
tur.forward(50);

Upvotes: 0

Related Questions