Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sequence = [int(i) for i in input().split()]
- command = input().split()
- while not command[0] == 'Finish':
- action = command[0]
- if action == 'Add':
- sequence.append(int(command[1]))
- elif action == 'Remove':
- if int(command[1]) in sequence:
- sequence.remove(int(command[1]))
- elif action == 'Replace':
- if int(command[1]) in sequence:
- sequence[sequence.index(int(command[1]))] = int(command[2])
- elif action == 'Collapse':
- for i in range(len(sequence)):
- if sequence[i] < int(command[1]):
- sequence[i] = 0
- sequence = [i for i in sequence if i != 0]
- command = input().split()
- print(*sequence)
Advertisement
Add Comment
Please, Sign In to add comment