Program to print the repeated elements in the list using Python


In this section of python programming, we will understand the code to print repeated elements in the list.

Program to print the repeated elements in the list


def rep(input_list):

    length = len(input_list)

    rep_input = []

    for i in range(length):

        j = i + 1

        for k in range(j, length):

            if input_list[i] == input_list[k] and input_list[i] not in rep_input:


    return rep_input


input_list = [2, 2, 3, 5,4,3,2,10,6,10,8,2,3,10,8]

print("The repeated elements are:", rep(input_list))



Program to print the repeated elements in the list Output


In the above python program, we have used two nested for loops. The two adjacent elements are checked if they are equal and also whether the element already exists in repeated element list ( which we have created to store the repeated elements). If the element is found repeated, the value is appended to rep_input list. After all the elements are traversed, the list is printed on the screen


  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.

    View all posts


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.