How to Find Out the Duplicated Values Present In a List:
some_list=['a','b','c','b','d','m','n','n']
my_list=sorted(some_list)
duplicates=[]
for i in my_list:
if my_list.count(i)>1:
if i not in duplicates:
duplicates.append(i)
print(duplicates)
def findDuplicates(items):
""" This function returns dict of duplicates items in Iterable
and how much times it gets repeated in key value pair"""
result = {}
item = sorted(items)
for i in item:
if item.count(i) > 1:
result.update({i: items.count(i)})
return result
print(findDuplicates([1,2,3,4,3,4,2,7,4,7,8]))
# output will be {2: 2, 3: 2, 4: 3, 7: 2}