Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stack = []
- def simple_stack():
- while True:
- operation= input().split()
- if operation[0] == "push":
- stack.append(int(operation[1]))
- print("ok")
- elif operation[0] == "pop":
- if len(stack)!=0:
- print(stack.pop(0))
- else:
- print("error")
- elif operation[0] == "front":
- print(stack[0])
- elif operation[0] == "back":
- if len(stack)!=0:
- print(stack[-1])
- else:
- print("error")
- elif operation[0] == "size":
- print(len(stack))
- elif operation[0] == "clear":
- stack.clear()
- print("ok")
- elif operation[0] == "exit":
- print("bye")
- break
- simple_stack()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement