itertools.product
itertools.product() generates the Cartesian product of input iterables — equivalent to nested for loops.
itertools.product() generates the Cartesian product of input iterables — equivalent to nested for loops.
from itertools import product
for combo in product("AB", [1, 2]):
print(combo)
# ("A", 1) ("A", 2) ("B", 1) ("B", 2)
Use repeat= to repeat the same iterable: product("AB", repeat=2).