10.11. Iterator Repeat — Python
Lazy evaluated
itertools.repeat(object[, times])
>>> from itertools import repeat >>> >>> >>> data = repeat('Beetlejuice', times=3) >>> >>> next(data) 'Beetlejuice' >>> >>> next(data) 'Beetlejuice' >>> >>> next(data) 'Beetlejuice' >>> >>> next(data) Traceback (most recent call last): StopIteration
10.11.1. Use Case - 1
>>> for string in repeat('hello', times=3): ... print(string) ... hello hello hello