ID EN
Itertools

chain

Python 3.11

Make an iterator that returns elements from the first iterable until it is exhausted, then proceeds to the next iterable, until all of the iterables are exhausted. Used for treating consecutive sequences as a single sequence. Roughly equivalent to:

Syntax

PYTHON
itertools.chain(*iterables)

Examples

Example 1
PYTHON
def chain(*iterables):
     chain('ABC', 'DEF') --> A B C D E F
    for it in iterables:
        for element in it:
            yield element