I am trying to have a python function that will return all possible ordered combinations between two lists. Ex a = [1, 2, 3] b = [4, 5, 6]
output: 123 126 153 156 423 426 453 456
The number of combinations returned should be 2^n where n is the length of the lists. The lists will always be the same length. The order of the lists must always remain the same. In the example: 1 or 4 must always be in the first position, 2 or 5 must always be in the second position, and 3 or 6 must always be in the third position.
UPDATED I have tried doing list(itertools.combinations(a + b, 3)), however, this returns all combinations including those that I do not want (ex 125. The order must be preserved so that only 1 or 4 can be in the first position, only 2 or 5 can be in the second position, and only 3 or 6 can be in the last position.
My issue is in actually creating the list of possible outputs. Once I have a list I can mess with it to display the way I want. (eventually, I want to output to CSV file).