Mira2706

2 zad

Jun 18th, 2023
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | Source Code | 0 0
  1. lst = [int(x) for x in input().split(" ")]
  2. command = input()
  3.  
  4. while command != "Finish":
  5.     command = command.split(" ")
  6.     if command[0] == "Add":
  7.         lst.append(command[1])
  8.     elif command[0] == "Remove":
  9.         if int(command[1]) in lst:
  10.             lst.remove(int(command[1]))
  11.     elif command[0] == "Replace":
  12.         i = lst.index(int(command[1]))
  13.         lst = lst[:i-1]+[command[2]]+lst[i:]
  14.         lst.remove(int(command[1]))
  15.     elif command[0] == "Collapse":
  16.         lst = [x for x in lst if x >= int(command[1])]
  17.  
  18.     command = input()
  19.  
  20. print(*lst, sep=" ")
Advertisement
Add Comment
Please, Sign In to add comment