fork download
  1. lst = [1, 2, 4, 5, 6, 2, 5, 2]
  2.  
  3. used = set()
  4. unique = [x for x in lst if x not in used and (used.add(x) or True)]
  5. print(unique)
  6.  
  7. from collections import Counter
  8. counter = Counter(lst)
  9.  
  10. unique = list(counter)
  11. print(unique)
  12.  
  13. single = [x for x,n in counter.items() if n==1]
  14. print(single)
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
[1, 2, 4, 5, 6]
[1, 2, 4, 5, 6]
[1, 4, 6]