Python – turtle.clear()
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
turtle.clear()
This function is used to delete the turtle’s drawings from the screen. Do not move state and position of the turtle as well as drawings of other turtles are not affected. It doesn’t require any argument.
Syntax : turtle.clear()
Parameters : None
Returns : Nothing
Below is the implementation of above method with some examples :
Example 1 :
# import packageimport turtle # motionturtle.forward(100)turtle.right(90)turtle.forward(100)turtle.right(90)turtle.forward(100) # clear the drawing# and remain turtle # as it isturtle.clear() |
Output :
Example 2 :
# import packageimport turtle # make a turtle object# and do some drawingt1 = turtle.Turtle()t1.up()t1.setpos(-100, 50)t1.down()t1.circle(50) # make a turtle object# and do some drawingt2 = turtle.Turtle()t2.up()t2.setpos(50, 50)t2.down()t2.circle(50) # make a turtle object# and do some drawingt3 = turtle.Turtle()t3.up()t3.setpos(50, -100)t3.down()t3.circle(50) # make a turtle object# and do some drawingt4 = turtle.Turtle()t4.up()t4.setpos(-100, -100)t4.down()t4.circle(50) # here we clear the work done by turtle # objects : t1 and t3 only but turtle # shape remain as it ist1.clear()t3.clear() |
Output :

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.


