Undo function in Python
I wrote a program that adds a tourism package (i.e. beginning and end dates, destination and price) to a list, can modify it and erase a specific package from the list if a condition is met (i.e. if the user inputs the 8th month of the year, the program will erase all of the packages which are in August from the list) However now I have to implement a function that undoes the last user-inputted function, so basically if I did the aforementioned instruction (deletes the packages which are in August from the list) and then I type undo, the list should be back to normal How would I proceed to do this? I thought of doing it this way first: https://pastebin.com/seqJpP6z but then I realised that I was working with packages that are dictionaries so I keep getting KeyError errors the full code is in Romanian and it's pretty long, (400+ lines) but I guess you can understand it a bit since it uses loan words mostly: https://pastebin.com/idQcpYK0