(seq1, seq2)
Interleave elements of `seq2` between consecutive elements of `seq1`.

    Example
    -------
    >>> list(interleave([1, 3, 5], [2, 4]))
    [1, 2, 3, 4, 5]
    >>> list(interleave([1, 2, 3, 4], repeat("<")))
    [1, '<', 2, '<', 3, '<', 4]
Interleave elements of `seq2` between consecutive elements of `seq1`.
Interleave elements of seq2 between consecutive elements of seq1 .
def interleave(seq1, seq2):
    """
    Interleave elements of `seq2` between consecutive elements of `seq1`.

    Example
    -------
    >>> list(interleave([1, 3, 5], [2, 4]))
    [1, 2, 3, 4, 5]
    >>> list(interleave([1, 2, 3, 4], repeat("<")))
    [1, '<', 2, '<', 3, '<', 4]
    """
    iterator1, iterator2 = iter(seq1), iter(seq2)
    try:
        leading = next(iterator1)
    except StopIteration:
        pass
    else:
        for element in iterator1:
            yield leading
            try:
                yield next(iterator2)
            except StopIteration:
                return
            leading = element
        yield leading
def interleave ( seq1 , seq2 ) : iterator1 , iterator2 = iter ( seq1 ) , iter ( seq2 ) try : leading = next ( iterator1 ) except StopIteration : pass else : for element in iterator1 : yield leading try : yield next ( iterator2 ) except StopIteration : return leading = element yield leading