Advertisement
Toxotsist

Task 2

Feb 25th, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import traceback
  2.  
  3.  
  4. def find_unique(lst):
  5.     count = 0
  6.     data = list(set(lst))
  7.     print(data)
  8.     true_data = []
  9.     for i in data:
  10.         for k in range(len(lst)):
  11.             if lst[k] == i:
  12.                 count += 1
  13.         if count == 1:
  14.             true_data.append(i)
  15.         count = 0
  16.     print(true_data)
  17.  
  18.     return true_data
  19.  
  20.  
  21. # Тесты
  22. try:
  23.     assert find_unique([1, 1, 1, 2, 1, 1]) == [2]
  24.     assert find_unique([0, 0, 0.55, 0, 0.66]) == [0.55, 0.66]
  25.     assert find_unique([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]
  26. except AssertionError:
  27.     print("TEST ERROR")
  28.     traceback.print_exc()
  29. else:
  30.     print("TEST PASSED")
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement