def group(iterable):
    """Groups items in an iterable

    Example:
        >>> list(group([1, 2, 2, 1, 1, 3]))
        [(1, 1), (2, 2), (1, 2), (3, 1)]
    """
    iterable = iter(iterable)
    amount_equal = 1
    prev = next(iterable)
    for item in iterable:
        if prev != item:
            yield prev, amount_equal
            amount_equal = 0
        amount_equal += 1
        prev = item
    yield prev, amount_equal
