Answers for "cartesian product in python"

1

cartesian product of a list python

import itertools

somelists = [
   [1, 2, 3],
   ['a', 'b'],
   [4, 5]
]
for element in itertools.product(*somelists):
    print(element)
Posted by: Guest on July-11-2021
0

python list comprehension cartesian product

[ (x, y) for x in xs for y in ys ]
Posted by: Guest on December-17-2020

Code answers related to "cartesian product in python"

Python Answers by Framework

Browse Popular Code Answers by Language