[Solved] python algorithm, find duplicates in list [closed]


Looks like a homework… Here’s a straight forward approach:

lst = ['apple','cherry','coffee','apple','coffee','coffee']

res = {}
for obj in lst:
    if obj not in res:
        res[obj] = 0
    res[obj] += 1

print res

solved python algorithm, find duplicates in list [closed]