Do and undo

actions is a list of strings. "undo" cancels the most recent action that has not already been undone; anything else is an action to do. Write final(actions) that returns the list of actions still in effect, in order. An "undo" with nothing to undo is ignored.

final(["add bread", "add milk", "undo", "add eggs"])  ->  ["add bread", "add eggs"]
final(["undo", "add milk"])                           ->  ["add milk"]
def final(actions):
    ...