ncycles

iteration_utilities.ncycles(iterable, n)

Returns the sequence elements n times.

Parameters:

iterable : iterable

Any iterable to repeat.

n : int

Number of repeatitions.

Returns:

repeated_iterable : generator

The iterable repeated n times.

Examples

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