Python Program to find duplicate elements in a list


In this program, you will learn how to find duplicate elements in a list in Python.


list1 = [10, 20, 10, 40, 50, 40, 10, 50, 50]

Example: How to find duplicate elements in a list in Python

list1 = [10, 20, 10, 40, 50, 40, 10, 50, 50]
v = 1

print("Duplicate elements are:")
for i in range(0, list1.__len__()):
    for j in range(i+1, list1.__len__()):
        if list1[i] == list1[j]:
            if v == 1 and list1[j] != '#':
                print(list1[i])
            list1[j] = '#'
            v = v + 1
    v = 1

Output:

Duplicate elements are:
10
40
50