-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
  • 42,427
  • 94
  • 291
  • 543

1 Answers1

3

Just unpack the function arguments from the list:

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

for combination in itertools.product(*A):
    ...
Eugene Yarmash
  • 131,677
  • 37
  • 301
  • 358