Python Program to Remove Duplicates from a List

In this example, we will write a program to remove duplicate items in a list using Python programming. To better understand this example, make sure you have knowledge of the following tutorials:-

Python Program to Remove Duplicates from a List

The output of the above program is:-

Original List: [10, 20, 30, 20, 10, 50, 60, 40, 80, 50, 40]
Unique List: [10, 20, 30, 50, 60, 40, 80]

Python Program to Remove Duplicates from a List using set() method

The output of the above program is:-

Original List: [10, 20, 30, 20, 10, 50, 60, 40, 80, 50, 40]
Unique List: [40, 10, 80, 50, 20, 60, 30]

Program Explanation:
Here, we define a list with several items that contain duplicate entries. To create a unique list, a new list is initialized with an empty value. If each of the element is not in the new list, then it is inserted else the loop is skipped and moved to next item in the list. In this way, we get only unique values in our new list.
SHARE Python Program to Remove Duplicates from a List

You may also like...

Leave a Reply

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

Share