A queue made of two stacks

A queue serves the oldest item first; a stack gives the newest. You can build a queue out of two stacks. Call them inbox and outbox. To add an item, push it onto inbox. To take the oldest item: if outbox is empty, pop every item from inbox and push each onto outbox, which reverses their order so the oldest is now on top; then pop from outbox. If outbox already has items, just pop from it.

Write drain(operations) that starts with two empty stacks (plain lists), applies a list of operations, and returns the list of items taken out, in order. Each operation is ("add", item) or ("take",). A take on an empty queue is ignored. Do not use pop(0) or a deque: the point is the two stacks.

drain([("add", "a"), ("add", "b"), ("take",), ("add", "c"), ("take",), ("take",)])  ->  ["a", "b", "c"]
def drain(operations):
    ...