yordan_yordanov

#2

Nov 7th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. sugar_cubes = list(map(int, input().split()))
  2. command = input().split()
  3.  
  4. while not command[0] == "Mort":
  5.  
  6. if command[0] == "Add":
  7. value = command[1]
  8. sugar_cubes.append(value)
  9.  
  10. elif command[0] == "Remove":
  11. value = int(command[1])
  12. if value in sugar_cubes:
  13. sugar_cubes.remove(value)
  14.  
  15. elif command[0] == "Replace":
  16. value = int(command[1])
  17. replacement = int(command[2])
  18. sugar_cubes = [replacement if el == value else el for el in sugar_cubes]
  19.  
  20. elif command[0] == "Collapse":
  21. value = int(command[1])
  22. for el in range(1, sugar_cubes + 1):
  23. if el < value:
  24. sugar_cubes.remove(el)
  25.  
  26. command = input().split()
  27.  
  28. print(" ".join(map(str, sugar_cubes)))
  29.  
Advertisement
Add Comment
Please, Sign In to add comment