eval.in

Paste #994126

Python — CPython 3.4.1, pasted 11 months ago (json)

1
2
3
4
5
6
import itertools

cycled = itertools.cycle(['alice', 'bob', 'carol'])

for count, value in zip(range(5), cycled):
    print(count, value)

Program Output

0 alice
1 bob
2 carol
3 alice
4 bob

OK (0.028 sec real, 0.032 sec wall, 8 MB, 28 syscalls)

Fork