Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

turtle.clearstamp() method in Python

  • Last Updated : 21 Jul, 2020

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.


The turtle.clearstamp() method is used to delete all or first/last n of turtle’s stamps. This method requires an argument of an integer. So, the stamp made with an id is cleared by it.

Syntax : turtle.clearstamp(stampid)


stampid – an integer, must be return value of previous stamp() call.

Below is the implementation of the above method with some examples :

Example 1 :


# import package
import turtle
# set turtle speed to slowest
# for better understandings
# motion with stamps
# and their ids
id1 = turtle.stamp()
id2 = turtle.stamp()
id3 = turtle.stamp()
# hide the turtle to
# clarify stamps
# clear the stamps
# of id : id1 and id3

Output :

Example 2 :


# import package
import turtle 
# list to store ids
ids = []
# loop to create motion
# with stamps
for i in range(12):
    # motion
    # stampid
    id = turtle.stamp()
# hide the turtle for 
# better understandings
# loop for clear stamps with 
# their ids using clearstamp
# half stamps are cleared
for i in range(len(lst)//2):

Output :

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!