-1

Though i found answer to this in the below link, i want to know how to achieve this using itertools in python. combinations using n arrays by selecting one element from each

Georgy
  • 12,464
  • 7
  • 65
  • 73
Santhosh Reddy
  • 123
  • 1
  • 6

1 Answers1

0
import itertools    

A = [[1], [2,3,4], [5]]
result = []
for c in itertools.product(*A):
    result.append(list(c))
print(result)

Reference: https://docs.python.org/3/library/itertools.html#itertools.product

tenacity
  • 456
  • 1
  • 5
  • 14