May-14-2018, 05:29 PM
I have a list of 25 lists of integers:
L = [[1,2,3], [4,5,6], [7,8],[9], …]
I want to create all possible combinations using all the integers from each list:
answer = [[1,4,7,9,...], [2,4,7,9,...], [3,4,7,9,...], [1,5,7,9,...], [2,5,7,9], …]
I tried:
L = [[1,2,3], [4,5,6], [7,8],[9], …]
I want to create all possible combinations using all the integers from each list:
answer = [[1,4,7,9,...], [2,4,7,9,...], [3,4,7,9,...], [1,5,7,9,...], [2,5,7,9], …]
I tried:
for a in L[0]: for b in L[1]: for c in L[2]: ... answer = [a,b,c,d, …]This works until the line length in IDLE exceeds about 90 characters, then the program refuses to run. Is there any way of using iterators, or any other solution?