Monday, June 11, 2018

Can you use a Python list as a stack?

A stack is a container of objects that are inserted (push) and removed(pop) according to last-in-first out (LIFO)principle. In this sense it is a limited access data structure. Physical example would be a stack of books.

Here is a picture of a stack.
A python list can be used in a stack. Although Python does not have push(), it has append() which serves the same purpose as far as a stack implementation is concerned.


PythonStack

No comments: