[Solved] How to get the cartesian product between sets in python without using loops?


Yes, with itertools product , map and set:

>>> from itertools import product
>>> A={1,2,3}
>>> B={4,5,6}
>>> list(map(set, product(A, B)))
[{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}]

1

solved How to get the cartesian product between sets in python without using loops?