Advertisement
GeorgiLukanov87

02 Lists Exam Preparation ll 100/100

Jul 19th, 2022
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. # 02 Lists Exam Preparation ll 100/100
  2. # https://judge.softuni.org/Contests/Practice/Index/1578#1
  3.  
  4.  
  5. data = input()
  6. unique_nums = []
  7. non_unique_nums = []
  8. while not data == 'stop playing':
  9.     while '  ' in data:
  10.         data = data.replace('  ', " ")
  11.     data = data.split(' ')
  12.     new_data = []
  13.     for index, el in enumerate(data):
  14.         if el != "":
  15.             data[index] = el.strip()
  16.             new_data.append(int(data[index]))
  17.  
  18.     if len(new_data) == len(set(new_data)):
  19.         for index, el in enumerate(new_data):
  20.             if el % 2 == 0:
  21.                 unique_nums.append(el + 2)
  22.             else:
  23.                 unique_nums.append(el)
  24.         print(f"Unique list: {','.join([str(x) for x in sorted(unique_nums)])}")
  25.         output = (sum(unique_nums) / len(unique_nums))
  26.         print(f"Output: {output:.2f}")
  27.         unique_nums.clear()
  28.  
  29.     else:
  30.         for index, el in enumerate(new_data):
  31.             if not el % 2 == 0:
  32.                 non_unique_nums.append(el + 3)
  33.             else:
  34.                 non_unique_nums.append(el)
  35.         print(f"Non-unique list: {':'.join([str(x) for x in sorted(non_unique_nums)])}")
  36.         output = (sum(non_unique_nums) / len(non_unique_nums))
  37.         print(f"Output: {output:.2f}")
  38.         non_unique_nums.clear()
  39.  
  40.     data = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement