Open this example in the interactive library
Source code
from itertools import product
print(list(product(['S', 'M'], ['red', 'blue'])))Sample output
[('S', 'red'), ('S', 'blue'), ('M', 'red'), ('M', 'blue')]
Generate a Cartesian product. A self-contained example using the Python standard library.
Open this example in the interactive library
from itertools import product
print(list(product(['S', 'M'], ['red', 'blue'])))[('S', 'red'), ('S', 'blue'), ('M', 'red'), ('M', 'blue')]