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.
turtle.clearstamp()
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)
Parameter:
stampid – an integer, must be return value of previous stamp() call.
Below is the implementation of the above method with some examples :
Example 1 :
Python3
import turtle
turtle.speed( 1 )
turtle.forward( 50 )
id1 = turtle.stamp()
turtle.forward( 50 )
id2 = turtle.stamp()
turtle.forward( 50 )
id3 = turtle.stamp()
turtle.ht()
turtle.clearstamp(id1)
turtle.clearstamp(id3)
|
Output :
Example 2 :
Python3
import turtle
ids = []
for i in range ( 12 ):
turtle.forward( 50 )
id = turtle.stamp()
lst.append( id )
turtle.right( 30 )
turtle.ht()
for i in range ( len (lst) / / 2 ):
turtle.clearstamp(lst[i])
|
Output :
Share your thoughts in the comments
Please Login to comment...