Suppose I have two lists of different sizes
a = [1, 2, 3]
b = ['a', 'b']
What is the Pythonic way to get a list of tuples of call possible combinations of one element from aand one element from b?
>>> print c
[(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b'), (3, 'a'), (3, 'b')]
The order of the elements in cdoes not matter.
A two-cycle solution is fortrivial, but it does not look like Pythonic.
source
share