# replicate¶

class iteration_utilities.replicate(iterable, times)

Replicates each item in the iterable for times times.

Parameters: iterable : iterable The iterable which contains the elements to be replicated. times : positive int The number of times each element is replicated. repeated_iterable : generator A generator containing the replicated items from iterable.

Examples

>>> from iteration_utilities import replicate
>>> ''.join(replicate('abc', 3))
'aaabbbccc'

>>> list(replicate(range(3), 5))
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]

__length_hint__()

Tries to estimate for the length of the instance (returns 0 if an estimation is not possible).

Note

Requires Python >= 3.4

current

(any type) The item that is currently replicated (readonly).

Only available if an item has been replicated.

New in version 0.6.

times

(int) The number of times each item is replicated (readonly).

New in version 0.6.

timescurrent

(int) A counter indicating how often the current item was already replicated (readonly).

New in version 0.6.