Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numbers = input().split()
- command = input()
- while not command == 'END':
- command = command.split()
- if 'start' in command:
- current_nums = command[3:]
- for n in range(len(current_nums)):
- numbers.insert(n, current_nums[n])
- elif 'end' in command:
- current_nums = command[3:]
- for n in range(len(current_nums)):
- numbers.append(current_nums[n])
- elif 'lower' in command:
- value = int(command[-1])
- numbers = [el for el in numbers if int(el) >= value]
- elif 'greater' in command:
- value = int(command[-1])
- numbers = [el for el in numbers if int(el) <= value]
- elif 'replace' in command:
- value = command[1]
- replacement = command[2]
- if value in numbers:
- index = numbers.index(value)
- numbers[index] = replacement
- elif 'index' in command:
- index = int(command[-1])
- if 0 <= index < len(numbers):
- numbers.pop(index)
- elif 'count' in command:
- count = int(command[-1])
- numbers = numbers[:-count]
- elif 'even' in command:
- print(' '.join([el for el in numbers if int(el) % 2 == 0]))
- elif 'odd' in command:
- print(' '.join([el for el in numbers if int(el) % 2 == 1]))
- command = input()
- print(', '.join(numbers))
Add Comment
Please, Sign In to add comment