Open this example in the interactive library
Source code
from itertools import cycle, islice
axes = cycle(['x', 'y', 'z'])
print(list(islice(axes, 7)))Sample output
['x', 'y', 'z', 'x', 'y', 'z', 'x']

Open this example in the interactive library
from itertools import cycle, islice
axes = cycle(['x', 'y', 'z'])
print(list(islice(axes, 7)))['x', 'y', 'z', 'x', 'y', 'z', 'x']