How do I check if there are duplicates in a flat list?

duplicates, list, python, string

Solution

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

>>> your_list = ['one', 'two', 'one']
>>> len(your_list) != len(set(your_list))
True

Problem

For example, given the list `['one', 'two', 'one']`, the algorithm should return `True`, whereas given `['one', 'two', 'three']` it should return `False`.

Original source

Related problems