Sichanov

NumberZ

Oct 24th, 2021
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. sequence = [int(i) for i in input().split()]
  2.  
  3. command = input().split()
  4.  
  5. while not command[0] == 'Finish':
  6.     action = command[0]
  7.     if action == 'Add':
  8.         sequence.append(int(command[1]))
  9.     elif action == 'Remove':
  10.         if int(command[1]) in sequence:
  11.             sequence.remove(int(command[1]))
  12.     elif action == 'Replace':
  13.         if int(command[1]) in sequence:
  14.             sequence[sequence.index(int(command[1]))] = int(command[2])
  15.     elif action == 'Collapse':
  16.         for i in range(len(sequence)):
  17.             if sequence[i] < int(command[1]):
  18.                 sequence[i] = 0
  19.         sequence = [i for i in sequence if i != 0]
  20.     command = input().split()
  21.  
  22. print(*sequence)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment