bl00dt3ars

Untitled

Aug 17th, 2021 (edited)
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. numbers = input().split()
  2. command = input()
  3.  
  4. while not command == 'END':
  5.     command = command.split()
  6.     if 'start' in command:
  7.         current_nums = command[3:]
  8.         for n in range(len(current_nums)):
  9.             numbers.insert(n, current_nums[n])
  10.     elif 'end' in command:
  11.         current_nums = command[3:]
  12.         for n in range(len(current_nums)):
  13.             numbers.append(current_nums[n])
  14.     elif 'lower' in command:
  15.         value = int(command[-1])
  16.         numbers = [el for el in numbers if int(el) >= value]
  17.     elif 'greater' in command:
  18.         value = int(command[-1])
  19.         numbers = [el for el in numbers if int(el) <= value]
  20.     elif 'replace' in command:
  21.         value = command[1]
  22.         replacement = command[2]
  23.         if value in numbers:
  24.             index = numbers.index(value)
  25.             numbers[index] = replacement
  26.     elif 'index' in command:
  27.         index = int(command[-1])
  28.         if 0 <= index < len(numbers):
  29.             numbers.pop(index)
  30.     elif 'count' in command:
  31.         count = int(command[-1])
  32.         numbers = numbers[:-count]
  33.     elif 'even' in command:
  34.         print(' '.join([el for el in numbers if int(el) % 2 == 0]))
  35.     elif 'odd' in command:
  36.         print(' '.join([el for el in numbers if int(el) % 2 == 1]))
  37.     command = input()
  38.  
  39. print(', '.join(numbers))
Add Comment
Please, Sign In to add comment