Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stack = []
- MAX_SIZE = 5
- def push(p):
- if len(stack)==MAX_SIZE:
- print("overflow")
- else:
- stack.append(p)
- return stack
- def pop():
- if len(stack) != 0:
- del stack[-1]
- else:
- print("underflow")
- return (stack)
- while True:
- print("1 for push ")
- print("2 for pop ")
- print("3 for exit")
- choice = int(input())
- if choice == 1:
- n = int(input("enter input: "))
- result = push(n)
- print(result)
- elif choice == 2:
- result = pop()
- print(result)
- elif choice == 3:
- break
- else:
- print("wrong choice")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement