check duplicates list python code example

Example 1: how to check if there are duplicates in a list python

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

Example 2: python check for duplicate

def checkDuplicate(user):
    if len(set(user)) < len(user):
        return True
    return False

Example 3: python duplicate list elements

def duplicate_list_elements(_list : list):
    duplicated_list = []

    for element in _list:
        duplicated_list.append(element)
        duplicated_list.append(element)

    return duplicated_list