How to get python unique values and duplicate values from a list
In this article, How to get python unique values and duplicate values from a list we will be understanding get unique values from a Python list. this article uses the python append method use to unique values get.
Example
list_data = [10,15,16,17,18,19,10,18,16,11,14,15]
duplicates_value = []
unique_value = {}
for value in list_data:
if value not in unique_value:
unique_value[value] = 1
else:
if unique_value[value] == 1:
duplicates_value.append(value)
unique_value[value] += 1
print ("Unique value : ")
for uni_val in unique_value:
print(uni_val)
print ("Duplicate value : ")
for dup_val in duplicates_value:
print(dup_val)
Output: Unique value : 10 15 16 17 18 19 11 14 Duplicate value : 10 18 16 15