flatten

iteration_utilities.flatten(iterable)

Flatten one level of nesting.

Parameters:

iterable : iterable

Any iterable to flatten.

Returns:

flattened_iterable : generator

The iterable with the first level of nesting flattened.

Examples

>>> from iteration_utilities import flatten
>>> list(flatten([[1,2,3,4], [4,3,2,1]]))
[1, 2, 3, 4, 4, 3, 2, 1]