Skip to main content

Stack

Instantiate an empty Stack.

Usage

Stack()

Methods

MethodDescription
is_emptyChecks if there are elements in the stack
peekReturns the element at the top of the stack
popReturns and remove the element at the top of the stack
pushInsert an item into the top of the stack

Example

from jellybeans.structures import Stackst = Stack()st.push(20)st.push(29)print(st) # 29 <- 20