from itertools import groupby


def group_count(i):
    """An iteration that returns tuples of items and the number of consecutive
    occurrences. Thus group_count('aabbbc') yields ('a',2), ('b',3), ('c',1)
    """

    return [(item, sum(1 for n in group)) for item, group in groupby(i)]