Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- number = int(input())
- my_stack = []
- for _ in range(number):
- query = input()
- query_split = query.split()
- command = query_split[0]
- if command == "1":
- current_number = int(query_split[1])
- my_stack.append(current_number)
- elif command == "2" and my_stack:
- my_stack.pop()
- elif command == "3" and my_stack:
- print(max(my_stack))
- elif command == "4" and my_stack:
- print(min(my_stack))
- reversed_stack = []
- while my_stack:
- reversed_stack.append(str(my_stack.pop()))
- print(", ".join(reversed_stack))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement