Suppose I have a nested loop of the form:
for i in List1:
for j in List2:
DoSomething(i,j)
Can it be done as follows:
for i,j in combine(List1, List2):
DoSomething(i,j)
Thanks in advance
So to clarify the combine function would do something as follows:
List1 = range(5)
List2 = range(5)
combine(List1, List2,)
>>> (0,0)
>>> (0,1)
>>> (0,2)
.
.
.
>>> (2,4)
>>> (3,0)
.
.
.
The itertools.product works perfectly
DoSomethingin a nested-loop without explicitly nesting loops. IMO the question is not very verbose, but clear in this extent. And the perfect answer has already been given: stackoverflow.com/a/43498876/6525140