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