thelist = [1, 2, 3, 4, 4, 5, 5, 6, 1]
def dup(x):
duplicate = []
unique = []
for i in x:
if i in unique:
duplicate.append(i)
else:
unique.append(i)
print("Duplicate values: ", duplicate)
print("Unique Values: ", unique)
dup(thelist)
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}
thelist = [1, 2, 3, 4, 4, 5, 5, 6, 1]
def dup(x):
duplicate = []
unique = []
for i in x:
if i in unique:
duplicate.append(i)
else:
unique.append(i)
print("Duplicate values: ", duplicate)
print("Unique Values: ", unique)
dup(thelist)
example = [1,2,3,4,5,6,7,8] #this is the list
for i in example:
example.append(example[i])