-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
  • 9,972
  • 7
  • 57
  • 66
Santhosh Reddy
  • 113
  • 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