For example, I have a code looks like this:
a = [1, 2] b = [4, 5]
How can I get something like this:
[(1,4), (1,5), (2,4), (2,5
Don't overlook the obvious:
out = [] for a in [1, 2]: for b in [4, 5]: out.append((a, b))
or list comprehensions:
a = [1, 2] b = [4, 5] out = [(x, y) for x in a for y in b]
Both produce out == [(1, 4), (1, 5), (2, 4), (2, 5)]
out == [(1, 4), (1, 5), (2, 4), (2, 5)]