(seq, multiple=True)
return groups
Splits a sequence into a list of lists of equal, adjacent elements.

    Examples
    ========

    >>> from sympy.utilities.iterables import group

    >>> group([1, 1, 1, 2, 2, 3])
    [[1, 1, 1], [2, 2], [3]]
    >>> group([1, 1, 1, 2, 2, 3], multiple=False)
    [(1, 3), (2, 2), (3, 1)]
    >>> group([1, 1, 3, 2, 2, 1], multiple=False)
    [(1, 2), (3, 1), (2, 2), (1, 1)]

    See Also
    ========
    multiset
Splits a sequence into a list of lists of equal, adjacent elements.
Splits a sequence into a list of lists of equal adjacent elements .
def group(seq, multiple=True):
    """
    Splits a sequence into a list of lists of equal, adjacent elements.

    Examples
    ========

    >>> from sympy.utilities.iterables import group

    >>> group([1, 1, 1, 2, 2, 3])
    [[1, 1, 1], [2, 2], [3]]
    >>> group([1, 1, 1, 2, 2, 3], multiple=False)
    [(1, 3), (2, 2), (3, 1)]
    >>> group([1, 1, 3, 2, 2, 1], multiple=False)
    [(1, 2), (3, 1), (2, 2), (1, 1)]

    See Also
    ========
    multiset
    """
    if not seq:
        return []

    current, groups = [seq[0]], []

    for elem in seq[1:]:
        if elem == current[-1]:
            current.append(elem)
        else:
            groups.append(current)
            current = [elem]

    groups.append(current)

    if multiple:
        return groups

    for i, current in enumerate(groups):
        groups[i] = (current[0], len(current))

    return groups
def group ( seq , multiple = True ) : if not seq : return [ ] current , groups = [ seq [ 0 ] ] , [ ] for elem in seq [ 1 : ] : if elem == current [ - 1 ] : current . append ( elem ) else : groups . append ( current ) current = [ elem ] groups . append ( current ) if multiple : return groups for i , current in enumerate ( groups ) : groups [ i ] = ( current [ 0 ] , len ( current ) ) return groups