python algorithm, find duplicates in list [closed]

>>> from collections import Counter
>>> Counter(['apple','cherry','coffee','apple','coffee','coffee'])
Counter({'coffee': 3, 'apple': 2, 'cherry': 1})
>>> for k,v in _.items():
...   print k,v
... 
cherry 1
coffee 3
apple 2

Leave a Comment