how to check if list has duplicate values code example
Example 1: python has duplicates
def has_duplicates(lst):
return len(lst) != len(set(lst))
x = [1,2,3,4,5,5]
has_duplicates(x) # True
Example 2: how to check if there are duplicates in a list python
>>> your_list = ['one', 'two', 'one']
>>> len(your_list) != len(set(your_list))
True