Iteration Classes

itertools.repeat()

Yield the same object repeatedly, not independent copies. Omit times for an unbounded iterator.

Formal Syntax & Structure

python syntaxpython
itertools.repeat(object[, times])

Parameters & Attributes

NameTypeDescription
objectobjectValue to repeat.
timesintNumber of repetitions; omission means unbounded.

Return Value

iterator

The iterator result described above.

Working Example

Example Snippetpython
import itertoolsprint(list(itertools.repeat("x",3)))
Python Reference