Python
stack:
list
(LIFO)
Goal
A stack grows and shrinks at one end — the
top
. The last item pushed is the first popped (LIFO). Run the program and predict the stack and each read; the code shows the actual
Python
call.
‹ Prev
Next ›
▶ Play
Reset
Program A
Program B
read result:
—
↑ top (push / pop here) · bottom is fixed
push (append)
read top
pop
New to stacks?
Learn the fundamentals in the Foundation Course →