Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
Python
stack = [] # Push stack.append('A') stack.append('B') stack.append('C') print("Stack: ", stack) # Pop element = stack.pop() print("Pop: ", element) # Peek topElement = stack[-1] print("Peek: ", topElement) # isEmpty isEmpty = not bool(stack) print("isEmpty: ", isEmpty) # Size print("Size: ",len(stack)) #Python
Python result:
Stack: ['A', 'B', 'C']
Pop: C
Peek: B
isEmpty: False
Size: 2