I am given an n-list-of-lists:
[
[a, b, c],
[p, q, r],
..,
..,
[x, y, z]
]
I am supposed to create a result by choosing one element from each lists. For example, the result for the above example should look like:
[
[a, p, .., x],
[a, p, .., y],
[a, p, .., z],
..
..
[c, r, .., z]
]
How can I implement it without using n-nested for loops? I cannot use n-nested for loops because we do not know the size of input n-list-of-lists until runtime..
itertools.productwas designed for this:Output: