unique lits on python

34

my_list  = [1,1,2,3,2,1,5]

# A set contains unique elements of which the order is not important
unique = list(set(my_list))

print(unique)
# Important: initial order might not be respected
# Output: [1,3,2,5]

Comments

Submit
0 Comments