teggy teggy - 3 years ago 209
Python Question

Check for duplicates in a flat list

Example 1



['one', 'two', 'one']
should return
True
.

Example 2



['one', 'two', 'three']
should return
False
.

Answer Source

Use set() to remove duplicates if all values are hashable:

>>> your_list = ['one', 'two', 'one']
>>> len(your_list) != len(set(your_list))
True
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download