23 Sep turtle.clone() function in Python
The turtle.clone() function creates and returns a clone of the current turtle. The clone has identical properties (position, heading, color) but its own undo buffer.
Syntax: turtle.clone()
Parameters: None.
Let us see an example to implement the turtle.clone() function in Python:
Demo61.py
# turtle.clone() function in Python
# Code by Studyopedia
import turtle
window = turtle.Screen()
t1 = turtle.Turtle()
t1.color("red")
t1.forward(100)
# Create a clone of the first turtle
t2 = t1.clone()
t2.color("blue")
t2.left(90)
t2.forward(100)
window.exitonclick()
The following is the output:

In the above code, we followed the below steps:
- Import module: import turtle loads the turtle graphics library.
- Create screen: window = turtle.Screen() opens the drawing window.
- Create first turtle: t1 = turtle.Turtle() creates a turtle you’ll control.
- Set first turtle color:color(“red”) sets its pen and outline color to red.
- Move first turtle:forward(100) draws a 100-unit red line.
- Clone turtle: t2 = t1.clone() creates a new turtle with the same position, heading, shape, speed, and pen settings as t1 at that moment, but independently controllable.
- Set second turtle color:color(“blue”) changes only the clone’s color to blue.
- Turn clone:left(90) rotates the clone 90° counterclockwise.
- Move clone:forward(100) draws a 100-unit blue line from the clone’s position.
- Close on click:exitonclick() waits for a mouse click, then closes the window.
If you liked the tutorial, spread the word and share the link and our website, Studyopedia, with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
- OpenCV Tutorial
- Python Tutorial
- NumPy Tutorial
- Pandas Tutorial
- Matplotlib Tutorial
- Generative AI Tutorial
- LangChain Tutorial
- RAG Tutorial
- Machine Learning Tutorial
- Deep Learning Tutorial
- Ollama Tutorial
- Retrieval Augmented Generation (RAG) Tutorial
- Copilot Tutorial
- Gemini Tutorial
- ChatGPT Tutorial
No Comments