A stack is a collection that stores arbitrary items in an order specified by Last-In/First-Out (LIFO) semantics. This means that the last item put into the stack is the first item available for removal from the stack. This is similar to a pile of lunch room trays – you access the most recent tray put on top first.
There is no native stack implementation in Python. Your choices for a stack are: using the built-in
list type, the
deque object from the
collections library, or
Here are resources and additional documentation about deque, LifoQueue, and linked lists: