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
| Name | Type | Description |
|---|---|---|
| object | object | Value to repeat. |
| times | int | Number of repetitions; omission means unbounded. |
Return Value
iterator
The iterator result described above.
Working Example
Example Snippetpython
import itertoolsprint(list(itertools.repeat("x",3)))