Let's say that I have this list with 3 items and every item contains 3 more items:
list = [ [1,2,3], [4,5,6], [7,8,9] ]
I want to create a 3**2 = 9 list which contains all the combinations of the items, which means
combination of (x,y,z) with x in [1,4,7], y in [2,5,8] and z in [3,6,9], so I will use list comprehension like this:
new_list =[(x,y,z) for x in [1,2,3] for y in [4,5,6] for z in [7,8,9]]
This is a "manual" approach. But if I want to use in my code large lists which every time vary in length, let's say a 20D list (20 items and every item contains 20 more items), how can I create a generic type of code?