Advertisement
boyan1324

23401

Feb 27th, 2024 (edited)
939
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.14 KB | None | 0 0
  1. integers_list = []
  2. commands_list = []
  3. number = input().split()
  4. for element in number:
  5.     if element.isdigit():
  6.         integers_list.append(int(element))
  7.     elif element.isalpha():
  8.         commands_list.append(element)
  9. for command in commands_list:
  10.     if command == "add":
  11.         integers_list.append(101)
  12.     elif command == "remove":
  13.         integers_list.remove(3)
  14.     elif command == "clear":
  15.         integers_list.clear()
  16.     elif command == "sort":
  17.         integers_list.sort(reverse=True)
  18.     else:
  19.         continue
  20. integers_list2 = []
  21. for digit in integers_list:
  22.     integers_list2.append(str(digit))
  23. print("-".join(integers_list2))
  24.  
  25. data = input().split("-")
  26. num_list = []
  27. command_list = []
  28. final_list = []
  29. for element in data:
  30.     if element.isdigit():
  31.         num_list.append(int(element))
  32.     elif element.isalpha():
  33.         command_list.append(element)
  34. for command in command_list:
  35.     if command == "A":
  36.         num_list.append(11)
  37.     elif command == "R":
  38.         for zero in num_list:
  39.             if zero % 10 == 0:
  40.                 num_list.remove(zero)
  41.                 break
  42.     elif command == "L":
  43.         print(len(num_list))
  44.     elif command == "S":
  45.         mid_of_list = len(num_list) // 2
  46.         num_list.insert(mid_of_list, sum(num_list))
  47.     elif command == "m":
  48.         num_list.insert(0, min(num_list))
  49.     elif command == "M":
  50.         num_list.append(max(num_list))
  51.     elif command == "s":
  52.         num_list.sort()
  53.     elif command == "r":
  54.         num_list.reverse()
  55.     elif command == "C":
  56.         num_list.clear()
  57.     elif command == "c":
  58.         eleven_count = num_list.count(11)
  59.         num_list.append(eleven_count)
  60.     elif command == "E":
  61.         int_list_copy = num_list.copy()
  62.         num_list.extend(int_list_copy)
  63.     elif command == "I":
  64.         eleven_index = num_list.index(11)
  65.         num_list.append(eleven_index)
  66.     elif command == "i":
  67.         num_list.insert(3, eleven_index)
  68.     elif command == "P":
  69.         num_list.pop()
  70.     elif command == "p":
  71.         print(num_list.pop(3))
  72. for digit in num_list:
  73.     final_list.append(str(digit))
  74. print(":".join(final_list))
  75.  
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement