Stack
Last In First Out - LIFO
In python, the list methods make it very easy to use a list as a stack, where the last element added is the first element retrieved (“last-in, first-out”). To add an item to the top of the stack, useappend()
. To retrieve an item from the top of the stack, usepop()
without an explicit index. For example:
Last updated