turtle.clear()-Python

Last Updated : 22 Aug, 2025

turtle.clear() function delete the turtle’s drawings from the screen. It does not affect the turtle’s current state (position, heading, color, etc.) and drawings made by other turtle objects remain untouched.

Syntax:

turtle.clear()

Parameters: This function does not take any parameters.

Returns: This function does not return anything. It simply clears the drawing made by the specific turtle object.

Examples




Example 1 : Clearing a single turtle’s drawing

python
import turtle

turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)

turtle.clear()
turtle.done()

Output :

Image

Explanation: The turtle draws part of a square, but turtle.clear() erases its entire drawing while keeping the turtle’s state (position, heading) unchanged.

Example 2 : Clearing drawings of selected turtles

python
import turtle

t1 = turtle.Turtle()
t1.up()
t1.setpos(-100, 50)
t1.down()
t1.circle(50)

t2 = turtle.Turtle()
t2.up()
t2.setpos(50, 50)
t2.down()
t2.circle(50)

t3 = turtle.Turtle()
t3.up()
t3.setpos(50, -100)
t3.down()
t3.circle(50)

t4 = turtle.Turtle()
t4.up()
t4.setpos(-100, -100)
t4.down()
t4.circle(50)

t1.clear()
t3.clear()

turtle.done()

Output :

Image

Explanation: Here, four turtles draw circles at different positions. Using clear() on t1 and t3 removes only their drawings, while t2 and t4 remain unaffected.

Comment
Article Tags:

Explore