I have a varying number of lists of varying length. I need to try to create all possibilities of having one item per list. How can this be done in Python?
Example
l1 = ['a', 'b', 'c']
l2 = [1, 2]
l3 = [6]
# Expected result:
[
['a', 1, 6],
['a', 2, 6],
['b', 1, 6],
['b', 2, 6],
['c', 1, 6],
['c', 2, 6],
]
I could have 3 loops in this case, but since this is for an ambiguous number of lists it doesn't scale.
I tried playing with itertools a bit but couldn't figure out what to use for my case and couldn't find similar questions here. So any help would be appreciated.