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

Solution 1:

There IS an undo function called (drumroll) undo() !

Ex: turtle.undo()

Apparently the number of Undos is limited by the UndoBuffer.

Source: https://www.geeksforgeeks.org/turtle-undo-function-in-python/

Solution 2:

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.