In python, I try to do this:
a=[1,2]
b=[3,4]
c=[5,6]
full=[]
for i in a:
for j in b:
for k in c:
full.append(i,j,k)
to get all possible combinations from list a,b,c and write into another list, it works fine. My question is: what should I do if there is unknown number of lists,such as
a = ([1,2]),b,c,d,e......
I am also aware there is itertools module can help, I need to use itertools.product
, which can take multiple arguments, but I dont know how to put all arguments in there. Any help will be appreciated.
I know my code above is the same as: list(itertools.product(a,b,c)) But I would like to know how to put unknown number of arguments in there. There might be more lists, and they might be different in length, and they have no patterns, so the 'repeat' or 'range' won't work either.