Alex Alex - 9 months ago 57
Python Question

How to make lists distinct?

I have a list in Python, how can I make it's values unique?


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.