I have a list of (label, count) tuples like this:
[(\'grape\', 100), (\'grape\', 3), (\'apple\', 15), (\'apple\', 10), (\'apple\', 4), (\'banana\', 3)]
using itertools and list comprehensions
import itertools [(key, sum(num for _, num in value)) for key, value in itertools.groupby(l, lambda x: x[0])]
Edit: as gnibbler pointed out: if l isn't already sorted replace it with sorted(l).
l
sorted(l)