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
- Take a list as input and create an empty list.
- With the help of for loop add elements from the given list to the empty list.
- If an element repeats then do not add it.
- 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]