Write a program to eliminate duplicate values in the list.
list1 = ['apple','bannana','cherry','apple']
list2 = []
print(list1)
for x in list1:
if x not in list2:
list2.append(x)
print(list2)
output:
['apple', 'bannana', 'cherry', 'apple']
['apple', 'bannana', 'cherry']
Comments
Post a Comment