Asked By – Alex
I have a list in Python, how can I make it’s values unique?
Now we will see solution for issue: How to make lists contain only distinct element in Python? [duplicate]
The simplest is to convert to a set then back to a list:
my_list = list(set(my_list))
One disadvantage with this is that it won’t preserve the order. You may also want to consider if a set would be a better data structure to use in the first place, instead of a list.