Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numbers = input().split(' ')
- numbers = list(map(int, numbers))
- command = input().split(" ")
- while True:
- if command[0] == "Finish":
- break
- if command[0] == "Add":
- numbers.append(command[1])
- elif command[0] == "Remove":
- numbers.remove(int(command[1]))
- elif command[0] == "Replace":
- value = int(command[1])
- replacement = int(command[2])
- counter = 0
- for i in range(len(numbers)):
- if numbers[i] == value:
- numbers.remove(value)
- numbers.insert(i, replacement)
- counter += 1
- if counter >= 1:
- break
- elif command[0] == "Collapse":
- collapse = int(command[1])
- numbers = [x for x in numbers if x > collapse]
- command = input().split(" ")
- numbers = list(map(str, numbers))
- output = " ".join(numbers)
- print(output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement