Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 02.Numbers , Mid Exam Fundamentals Python June.2022
- data = list(map(int, input().split(' ')))
- command = input()
- less_than_collapse = []
- while not command == 'Finish':
- details = command.split()
- if details[0] == 'Add':
- add_value = int(details[1])
- data.append(add_value)
- elif details[0] == 'Remove':
- remove_value = int(details[1])
- if remove_value in data:
- data.remove(remove_value)
- elif details[0] == 'Replace':
- value = int(details[1])
- replace = int(details[2])
- for index, el in enumerate(data):
- if el == value:
- data[index] = replace
- break
- elif details[0] == 'Collapse':
- collapse_value = int(details[1])
- for el in data:
- if not el < collapse_value:
- less_than_collapse.append(el)
- data.clear()
- data = less_than_collapse
- command = input()
- print(*data, sep=" ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement