turtle.clearstamps() 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.clearstamps()
The turtle.clearstamps() method is used to delete all or first/last n of turtle’s stamps. This method requires an argument of an integer. So, the n stamps made are cleared by it.
Syntax : turtle.clearstamps(n=None)
Optional argument: n — an integer
- If n is None, delete all of pen’s stamps,
- else if n > 0 delete first n stamps
- else if n < 0 delete last n stamps.
Below is the implementation of the above method with some examples :
Example 1 :
Python3
import turtle
turtle.speed( 1 )
turtle.forward( 50 )
turtle.stamp()
turtle.forward( 50 )
turtle.stamp()
turtle.forward( 50 )
turtle.stamp()
turtle.ht()
turtle.clearstamps()
|
Output :
Example 2 :
Python3
import turtle
for i in range ( 12 ):
turtle.forward( 50 )
turtle.stamp()
turtle.right( 30 )
turtle.ht()
turtle.clearstamps( 8 )
|
Output :
Share your thoughts in the comments
Please Login to comment...