-1

If I have list of lists

A = [a, b, ..., d]

in Python, then how can I apply itertools.product to it?

I know that I can crossproduct over explicit lists

import itertools
for combination in itertools.product(a, b, ..., d):
   ...

but how to deal with dynamic list of lists like A?

Dims
  • 47,675
  • 117
  • 331
  • 600

1 Answers1

3

Just unpack the function arguments from the list:

A = [a, b, ..., d] 

for combination in itertools.product(*A):
    ...
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378