Does turtle something like a Ctrl-Z (Undo) function?

Viewed 148

I'm trying to code an whiteboard program so I need to have something like Ctrl-Z (Undo) function in it.

2 Answers

Like pointed out in this great answer, there is a handy undo function built into turtle.

To elaborate, here is the turtle.undo function's documentation that can be accessed through print(help(turtle.undo)) or print(turtle.undo.__doc__):

undo()

undo (repeatedly) the last turtle action.

No argument.

undo (repeatedly) the last turtle action. Number of available undo actions is determined by the size of the undobuffer.

Example:

   >>> for i in range(4):
   ...     fd(50); lt(80)
   ...
   >>> for i in range(8):
   ...     undo()
   ...

See this answer for the implementation.

Related