Program To Check If There Is A Duplicate Element Present In The List Or Not.if That Is Present In The List Then Remove It
April 28, 2023 by Primegyan 2.05k
In This article we are going to share solution for Write a program to check if there is a duplicate element present in the list or not.if that is present in the list then remove it from the list. which is asked in o level practical exam in july 2022. so lets try this code..
Code
numbers=[12,1,6,13,75,14,12,17,1,15]
print("Original item are",numbers)
result=[]
for i in numbers:
if i not in result:
result.append(i)
if numbers==result:
print("Duplicate item does not exist")
else:
numbers=result
print("Duplicate items removed! New list is: ",numbers)
OUTPUT:
Original item are [12, 1, 6, 13, 75, 14, 12, 17, 1, 15]
Duplicate items removed! New list is: [12, 1, 6, 13, 75, 14, 17, 15]
Video Solution: