How do you remove duplicates from an array?
In python it is simple program
- list = [1,3,4,6,3,1,8,9,6]
- print ("The original list is : " + str(list))
- list1 = []
- for i in list:
- if i not in list1:
- list.append(i)
- print ("The list after removing duplicates : " + str(list1))
Output:
- The original list is : [1,3,4,6,3,1,8,9,6]
- The list after removing duplicates : [1,2,4,6,8,9]
Comments
Post a Comment