Python - Stack

> Procedural Languages > Python > Python - Data Type

1 - About

To implement a stack, you use a list in Python

3 - Example

stack = [3, 4, 5]
stack.append(6)
stack.append(7)
stack
[3, 4, 5, 6, 7]
stack.pop()
7
stack
[3, 4, 5, 6]
stack.pop()
6
stack.pop()
[3, 4]
Advertising

4 - Documentation / Reference