Friday, September 5, 2025
HomeLanguagesturtle.undobufferentries() function in Python

turtle.undobufferentries() function in Python

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.undobufferentries()

This function is used to return the count of entries in the undobuffer. It doesn’t require any argument.

Syntax :

turtle.undobufferentries()

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

Example 1 :

Python3




# import package
import turtle
  
# loop for motion
for i in range(50):
    turtle.forward(20+2*i)
    turtle.right(90)
  
# check the undo buffer size
# it is loop iteration*turtle's statement
# i.e; 50*2 = 100
print(turtle.undobufferentries())


Output :

100

Example 2 :

Python3




# import package
import turtle
  
# loop for motion
for i in range(50):
    turtle.forward(20+2*i)
    turtle.right(90)
  
# call undo() method till the 
# undobuffer length
while turtle.undobufferentries():
    turtle.undo()


Output :

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS