Given:
x = ['a','b','c','d','e']
y = ['1','2','3']
I’d like iterate resulting in:
a, 1
b, 2
c, 3
d, 1
e, 2
a, 3
b, 1
… where the two iterables cycle independently until a given count.
Python’s cycle(iterable) can do this w/ 1 iterable. Functions such as map and itertools.izip_longest can take a function to handle None, but do not provide the built-in auto-repeat.
A not-so-crafty idea is to just concatenate each list to a certain size from which I can iterate evenly. (Boooo!)
Suggestions? Thanks in advance.
1 Answer