Ask coding questions

← Back to all posts
Whats the Error?
Cdogo (2)

Python is giving me an error that says turtle is not defined even though I imported it in the first line.
what should I do?

Voters
Cdogo (2)
Commentshotnewtop
DJWang (1150)

Hi John! You have forgotten to make a parameter for the turtle! Instead of

def makeDots(num):
	import turtle
	ret = {}
	t = Turtle()
	t.penup()

Try this:

import turtle

T = turtle.Turtle()
def makeDots(num,t):
	import turtle
	ret = {}
	t = Turtle()
	t.penup()

Then wherever you use the turtle outside the function just change it to capitalized or another name.