Alex Alex - 2 years ago 118
Python Question

How to make lists distinct?

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download