Reverse with a stack
Write reverse_items(items) that returns a new list with the items in
reverse order, by pushing every item onto a stack and then popping them all
off. Leave items unchanged. Slicing or reverse would also work; the
point here is to practise the stack.
reverse_items(["apple", "bread", "milk"]) -> ["milk", "bread", "apple"]
reverse_items([]) -> []
def reverse_items(items):
stack = []
for item in items:
...
result = []
while stack:
...
return result