I have a list which has repeating items and I want a list of the unique items with their frequency.
For example, I have [\'a\', \'a\', \'b\', \'b\', \'b\']
[\'a\', \'a\', \'b\', \'b\', \'b\']
With Python 2.7+, you can use collections.Counter.
Otherwise, see this counter receipe.
Under Python 2.7+:
from collections import Counter input = ['a', 'a', 'b', 'b', 'b'] c = Counter( input ) print( c.items() )
Output is:
[('a', 2), ('b', 3)]