unique in list python code example
Example 1: duplicate in list python
a = [1,2,3,2,1,5,6,5,5,5]
import collections
print([item for item, count in collections.Counter(a).items() if count > 1])
## [1, 2, 5]
Example 2: python list with only unique values
my_list = list(set(my_list))
Example 3: unique list values python ordered
def get_unique(seq):
seen = set()
seen_add = seen.add
return [x for x in seq if not (x in seen or seen_add(x))]
Example 4: minimum in list python
c=[4, 10, 2, 57]
print(min(c))
# 2