7. Problem to remove all the duplicate elements from a list.

In this program, we will take a user input as a list & remove all the duplicate elements with the help of the below-given steps.

Remove duplicates from list:

Steps to solve the program
  1. Take a list as input and create an empty list.
  2. With the help of for loop add elements from the given list to the empty list.
  3. If an element repeats then do not add it.
  4. Print the list to see the output.
				
					#Input list
list1 = [5,7,8,2,5,0,7,2]
 
#Creating empty list
list2 = []

for value in list1:
    if value not in list2:
        list2.append(value)
        
#Printing Output
print(list2)

				
			

Output :

				
					[5, 7, 8, 2, 0]
				
			

Related Articles

Differentiate even and odd elements

Combination of 2 elements from the list whose sum is 10.

Leave a Comment