LearnPy Hub
← Classes & Objects problems
Medium

Stack Class

Write a Stack class with push, pop (return None when empty), peek and size. Process commands push X, pop, peek and print results of pop/peek, then the size.

Input

n, then n commands.

Output

Results, then the size.

Sample 1

Input
4
push a
push b
pop
peek
Output
b
a
1

Sample 2

Input
1
pop
Output
None
0
solution.py
Output appears here
Stack Class · Python practice problem · LearnPy Hub