Stack
easy 14 minA stack is a linear data structure where items are added and removed at the same end, the top.
A stack class backed by a Python list
Read it, run it, change a line and run it again.
Loading editor…
The end of the list is the top, so push, pop and peek are O(1). Popping or peeking an empty stack raises IndexError instead of failing silently.