TRT / KID / 01
Python and AI for kids
Turtle first, then games.
Open the syllabusUnited States · Grade 3 to Grade 12 · Python turtle
For many students, turtle is the first typed Python they meet, whether in a middle school computer science elective, an after-school club or a summer camp. It is also where they meet their first confusing failure: an error before anything draws, a window that flashes and vanishes, or arrow keys that do nothing. Almost every case comes from a short list of causes. This page goes through them with the messages Python really prints. Each message is either quoted from the official docs or reproduced on our own test laptop (Python 3.13.6, Tk 8.6), and every one says which. Then it shows how to write text on the turtle screen.
Live teaching since 2020 · 10,000+ students · Turtle graphics in our Python course for kids
In short
When Python turtle is not working, check four things in order: your file is not named turtle.py (that file hides the real module), the program ends with turtle.done() so the window stays open, tkinter is installed (turtle needs it), and screen.listen() is called if you use keys. Text goes on screen with write(). At Modern Age Coders, turtle graphics is part of our live Python course for children in Grade 3 and above, taught in a group batch or one to one.
Learn it with a teacher
Turtle is a starting point. Each course below begins there and moves on to real programs.

TRT / 01
Grades 3 to 8. Turtle art first, then games and smart projects.
Open the syllabus →
TRT / 02
Ages 10 to 15. Angles, shapes and patterns drawn in Python.
Open the syllabus →
TRT / 03
Ages 13 to 18. From graphics to full projects.
Open the syllabus →Match your symptom
Find the row that matches what happened on your screen. Each cause is explained further down the page.
| What happens | What Python printed | Most likely cause |
|---|---|---|
| Error on the first turtle line | module 'turtle' has no attribute 'Turtle' | Your own file is named turtle.py |
| Error before anything runs | Standard library module '_tkinter' was not found | tkinter is missing from this Python install |
| A window flashes and closes | Nothing at all | No turtle.done() at the end of the program |
| Arrow keys do nothing | Nothing at all | screen.listen() was never called |
| Error naming a color | bad color string: bleu | A misspelled color name |
| Error with three numbers as a color | bad color sequence: (240, 160, 80) | Color mode is 1.0, not 255 |
| Error on a turtle command | 'Turtle' object has no attribute 'forwad'. Did you mean: 'forward'? | A typo in the command name |
| Error after closing the window | invalid command name ".!canvas" | A turtle command ran after the window was gone |
The _tkinter and color-sequence messages are quoted from the turtle documentation; the others come from our own run of Python 3.13.6 with Tk 8.6 on Windows 11, 17 October 2026. We are not connected with the Python Software Foundation.
Cause number one
It feels sensible to save your first turtle program as turtle.py. It is also a very common reason import turtle fails, because Python then imports your file instead of the real module.
# Saved as turtle.py (the bug is the file name, ours) import turtle t = turtle.Turtle() t.forward(100) turtle.done() # Our run, Python 3.13.6: # AttributeError: module 'turtle' has no attribute # 'Turtle' (consider renaming 'turtle.py' since it # has the same name as the standard library module # named 'turtle' and prevents importing that # standard library module). Did you mean: 'turtle'?
Python 3.13 added the "consider renaming" hint; the Python 3.13 release notes show the same message for a file named random.py. Older versions print only the first part, which is far less helpful.
The Python tutorial explains that "The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path." So when your folder holds turtle.py, import turtle finds that file first.
The tutorial adds, flatly: "This is an error unless the replacement is intended." Your file has no Turtle class in it, so the very next line fails.
Rename the file to something like star_card.py or my_drawing.py. Anything except the name of a module you import.
Run the renamed file and read the first line of any new error. With the real module back, the program either draws or fails on a different, honest line.
Check the folder for other borrowed names too. A file called random.py or math.py breaks those modules in exactly the same way.
The window
Turtle draws in a desktop window made by tkinter, Python's interface to the Tk toolkit. Window problems tend to come from that window being closed too early, never being allowed to open, or not being available at all.
When the last line finishes, the program ends and takes the window with it. The documentation says turtle.done() "Must be the last statement in a turtle graphics program." Add it, or use turtle.exitonclick() to close on a mouse click.
The documentation is clear: "Turtle graphics requires the tkinter optional module." If you see an error mentioning _tkinter, this Python install has no Tk support. Running python -m tkinter should open a small test window when tkinter works.
This usually happens when a program is run twice in one session, or a loop never ends. Close the window, restart the Python shell or kernel, and run the file fresh. Add turtle.done() once, at the very end.
| Setting | What the documentation says | What that means for a student |
|---|---|---|
| python.org Python on Windows or macOS | "The python.org installers for Windows and macOS include it" | Turtle should work after a normal install |
| Python on Linux, including some school setups | Some Linux distributions "may package it separately" | Ask whoever set up the computer to add the Tk package |
| IDLE, the editor that comes with Python | done() must not be used if IDLE runs in -n mode | In a normal IDLE install, done() is fine |
| A browser notebook running on a remote server | Not covered by the turtle documentation | Our reasoning: the code runs on another machine, so there is no desktop window for tkinter to open on your screen |
Quotes from the turtle and tkinter documentation, read 17 October 2026. tkinter lists Tcl/Tk 8.5.12 as its minimum supported version; our test machine reported Tk 8.6.
How to write in turtle
Searches for how to write in turtle mostly mean one thing: putting words on the drawing. The command is write(), and the documentation gives its full form as write(arg, move=False, align='left', font=('Arial', 8, 'normal')).
# star_card.py (ours; any name except turtle.py)
import turtle
screen = turtle.Screen()
screen.bgcolor("lightyellow")
t = turtle.Turtle()
t.color("purple")
t.speed(6) # 6 is "normal"
for side in range(5):
t.forward(150)
t.right(144) # 5 x 144 = 720: two full turns
t.penup() # move without drawing
t.goto(75, -60)
t.write("Happy birthday, Ava", align="center",
font=("Arial", 18, "normal"))
t.hideturtle()
turtle.done() # keeps the window openWe ran a test copy of this program: the star closed neatly and the turtle finished at (75.00, -60.00) facing heading 0.0, because five turns of 144 degrees add up to 720, exactly two full turns.
| Part | What it does | Our tip |
|---|---|---|
| arg | The object to write; its string form appears on screen | Numbers work alone, but joining them to text needs str() |
| align | One of "left", "center" or "right", measured from the turtle | Use "center" for titles and labels |
| font | A triple: (fontname, fontsize, fonttype) | Size 8 is the default and is tiny; try 16 to 24 |
| move | If true, the pen moves to the bottom-right corner of the text | Leave it False unless you are writing a line in pieces |
# The write() mistake (ours)
points = 42
t.write(points + " points") # TypeError
# Our run: TypeError: unsupported operand type(s)
# for +: 'int' and 'str'
t.write(str(points) + " points") # works
t.write(f"{points} points") # also worksThe error is ordinary Python, not turtle: a number and a string cannot be added. Convert the number first.
Keys, colors and speed
Once the window opens, the next round of trouble usually comes from three settings that the documentation explains in a line each.
# arrow_keys.py (ours)
import turtle
screen = turtle.Screen()
t = turtle.Turtle()
def go_up():
t.forward(20)
def turn_left():
t.left(30)
screen.onkey(go_up, "Up")
screen.onkey(turn_left, "Left")
screen.listen() # without this, keys are ignored
turtle.done()The documentation says that to register key events, the TurtleScreen "must have the focus", which is what listen() does. Click the turtle window once too, so the keyboard is talking to it and not to your editor.
A color name is a Tk color specification string, which the documentation illustrates with "red", "yellow", or "#33cc8c". A misspelling such as "bleu" stops the program with bad color string: bleu.
Three numbers like (240, 160, 80) only work after screen.colormode(255). In the default mode each value must be between 0 and 1.0, and the documentation shows the resulting error: bad color sequence: (240, 160, 80).
speed() takes 0 to 10 or a word. The documentation maps "fastest" to 0, "normal" to 6 and "slowest" to 1, and warns that "speed = 0 means that no animation takes place".
So speed(0) is not "stopped"; it is "draw instantly". For large drawings, students also use tracer(0) with update() to draw everything at once.
Asking the user for input inside turtle works too: textinput() pops up a dialog and, as the documentation notes, returns None if the dialog is canceled, so check for None before using the answer.
Checklist
Our checklist, in the order our teachers use it. Stop as soon as one check explains the error.
If a program keeps drawing after the window has gone, tkinter has nothing to draw on. In our test, calling turtle.bye() and then t.forward(50) ended with _tkinter.TclError: invalid command name ".!canvas".
The fix is structure, not luck: draw everything first, then let turtle.done() hold the window open as the final line.
If the drawing is a graded school assignment, we will explain why the program fails and teach the idea behind it, but we do not draw anyone's assignment for them.
In a lesson, students bring the broken file, and the teacher asks them to read the error aloud first. Fixing it themselves is the part that sticks.
Where turtle leads
Turtle was built for learning. The documentation describes it as an implementation of the drawing tools introduced in Logo in 1967 and notes that its "instant, visible feedback makes it an effective way for learners to encounter programming concepts."
| Classes | What gets drawn | The idea behind it |
|---|---|---|
| 1 to 2 | Squares, triangles, a house | Sequence: commands run in order |
| 3 to 4 | Stars and spirals with for loops | Loops, and angles that add up to full turns |
| 5 to 6 | Functions like draw_flower(size) | Functions and parameters |
| 7 to 8 | Random colors and positions | Variables, random numbers, color modes |
| 9 to 10 | An arrow-key drawing game | Events and the main loop |
| 11 to 12 | A card or poster with text | Putting it all together; write() and layout |
After turtle, children move on to games and data. For age-by-age starting points, see Python for 10 year olds and Python for 12 year olds; for younger children, online coding classes for US kids.
From first line to first game
Where a young coder might be, and what comes next.
| Stage | What it looks like |
|---|---|
| 1. Typist | Copies commands line by line from a worksheet |
| 2. Looper | Replaces repeated lines with a for loop |
| 3. Builder | Writes functions that draw shapes of any size |
| 4. Game maker | Uses keys, events and text to make something interactive |
A child who can explain why five turns of 144 degrees make a star is doing geometry and programming at once.
Errors are part of the work. The useful question is whether your child reads them before asking for help.
Never name your file turtle.py. Give it a name about what it draws.
End every program with turtle.done(). Then the window waits for you.
The catalogue
Taught live online by a regular teacher, in a batch or one to one.
TRT / KID / 01
Turtle first, then games.
Open the syllabusTRT / KID / 02
Drag-and-drop before typing.
Open the syllabusTRT / KID / 03
Angles and patterns in code.
Open the syllabusTRT / TEN / 01
Past turtle into real apps.
Open the syllabusTRT / TEN / 02
Animation and generative art.
Open the syllabusTRT / TEN / 03
Drawing and games in a browser.
Open the syllabusTRT / PRO / 01
Loops and logic, harder puzzles.
Open the syllabusTRT / PRO / 02
Python models, ages 13 to 18.
Open the syllabusTRT / PRO / 03
Zero to advanced, ages 18 and up.
Open the syllabusHow lessons run
Weekdays or weekends, flexible: choose your batch, or for a very personalised plan choose 1-on-1 at your convenience, weekend mornings or weekdays.
Weekdays
Batches placed for US time zones.
Weekends
Popular with younger children.
1-on-1
A schedule built around your child.
One teacher across the term.
The teacher sees the turtle window too.
We start from the error.
Children fix their own code.
A laptop with Python is enough.
Fifteen to twenty, or one child.
Student work
Work from learners whose first programs were turtle shapes too. More on the student labs page.

AI and ML
An AI nutrition coach that reads what you eat and works you toward a target.

AI and ML
A chatbot that answers mathematics and programming questions, built and deployed by a student.

AI and ML
An assistant that helps a young person recognise unsafe situations online.

Web app
A weather forecasting site with live conditions for any location.
Fees
Turtle comes free with Python. You pay only for live lessons, charged monthly in US dollars; there is no term-long commitment, and you may stop after any month.
Free first class
USD 0
no card required
Group batch
USD 100
a month, billed in US dollars
One to one
USD 150
a month, billed in US dollars
What families say
Google reviews from parents, unedited.
★★★★★
"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."
Ria Mukherjee
Parent
★★★★★
"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."
Samriddha Mondal
Student
★★★★★
"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."
Vansh Agarwal
Student
★★★★★
"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."
Sonam Oswal
Parent of Dhairya
★★★★★
"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."
Sonu Goyal
Parent
★★★★★
"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."
Ritu Kedia
Parent
Questions families ask
A very common cause is a file of your own named turtle.py in the same folder, which Python imports instead of the real module. Rename it. If the error mentions _tkinter instead, this Python install is missing tkinter, which turtle needs.
The program ended. Put turtle.done() as the last line, which the Python documentation says must be the last statement in a turtle graphics program, or use turtle.exitonclick() to close it with a click.
Use write(), for example t.write("Hello", align="center", font=("Arial", 18, "normal")). The text appears at the turtle's position. Convert numbers with str() before joining them to words.
Call screen.listen() after setting up onkey(), and click the turtle window once so it has the focus. The documentation says the screen must have the focus to register key events.
Yes. The Python documentation says turtle graphics requires the tkinter optional module. The python.org installers for Windows and macOS include it, and running python -m tkinter shows a test window when it is working.
The color name is not one Tk recognizes, often a typo. Use a real name such as red or a hex code such as #33cc8c. For number triples up to 255, call screen.colormode(255) first.
Turtle needs a desktop window from tkinter, so it works where a full Python install with tkinter can run. On a school Chromebook that depends on how the device is set up, so ask your teacher which Python environment the class uses.
No. We explain why a program fails and teach the idea so the student can finish their own work. We never complete graded assignments.
Weekdays or weekends, flexible. Choose your batch, or for a very personalised plan choose 1-on-1 at your convenience, weekend mornings or weekdays.
The first lesson costs nothing. After that you pay month by month for live teaching, and the fees section on this page shows the amount in US dollars.
Elsewhere on this site
More for US families whose children are starting Python.
Our full set of pages for US families.
Classes for ages 6 to 14.
A starting point for fifth graders.
A starting point for seventh graders.
A method for any bug, turtle or not.
Projects our learners have shipped.
Scratch not working? Saving, sign-in, school network and tablet fixes, from the Scratch Help Center.
MakeCode Arcade help: jumping, gravity, tilemap levels and lost projects.
Roblox Studio errors from the Creator docs: 403, 502, HTTP, endless waits.
Start here
Tell us what your child is drawing and where it goes wrong. The teacher opens the same program in the first lesson.
Before booking, you can read how a lesson works or browse all our courses with their syllabuses.
WhatsApp us · +91 91233 66161 · connect@modernagecoders.com
Our teachers are in India and teach entirely over video, so families anywhere in the US join from home. A WhatsApp message gets the quickest answer.
A priority demo is a full class of about 45 to 60 minutes. After the class the mentor sends a written skill report and a personal learning roadmap on WhatsApp. If you enrol, the demo fee is adjusted against your first month's fee. Share your demo Order ID with us on WhatsApp and we take it off.
Book a priority demo