
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python program to remove Duplicates elements from a List?
One list is given with duplicate element, our task is create another list which contains the element of without duplicates.
Example
A::[2,3,4,3,4,6,78,90] Output::[2,3,4,6,78,90]
Algorithm
Step 1: create a list. Step 2: create a new list which is empty. Step 3: traverse every element in list. Step 4: if element is not present in the list return true. Step 5: append in the new list. Step 6: display new list.
Example Code
# To remove duplicate elements defremoveduplicateele(A): newlist = [] for n in A: if n not in newlist: newlist.append(n) returnnewlist # Driver Code A=list() n=int(input("Enter the size of the List ::")) print("Enter the number ::") fori in range(int(n)): k=int(input("")) A.append(int(k)) print("THE NEW LIST IS ::>",removeduplicateele(A))
output
Enter the size of the List ::5 Enter the number :: 10 20 30 20 10 THE LIST IS ::> [10, 20, 30]
- Related Articles
- Java program to remove duplicates elements from a List
- Python - Ways to remove duplicates from list
- Python Program to Remove Palindromic Elements from a List
- Java Program to Remove Duplicates from an Array List
- Python program to remove duplicate elements from a Circular Linked List
- How do you remove duplicates from a list in Python?
- Remove duplicates from a List in C#
- Python program to remove duplicate elements from a Doubly Linked List\n
- Python program to remove all duplicates word from a given sentence.
- Python program to print duplicates from a list of integers?
- C# program to remove duplicate elements from a List
- Remove Duplicates from Sorted List in C++
- Remove Duplicates from a Sorted Linked List Using Recursion
- Golang program to remove elements from the linked list
- How to remove duplicates from a sorted linked list in android?

Advertisements