Hello,

I have this code scripts:

For clarification:

This is my code for number 2:

I have this code scripts:

for variables in itertools.product([0, 1], repeat=(number*2)): # set of variables for a,ap,b,bp,c,cp like 000000 000001 000011.... #a,ap,b,bp,c,cp= variables[0],variables[1],variables[2],variables[3],variables[4],variables[5] #giving value for a,ap,b,bp,c,cp a,ap,b,bp= variables[0],variables[1],variables[2],variables[3] finallist = [(a,b),(a,bp),(ap,b),(ap,bp)] #binary combination of a,ap,b,bp,c,cp #finallist = [i for i in range(hidden_variables)] #finallist = [(a,b,c),(a,b,cp),(a,bp,c),(a,bp,cp),(ap,b,c),(ap,b,cp),(ap,bp,c),(ap,bp,cp)]I know that "variables" is already an array but after that I want to group this list according to value of "number" instead of writing by hand . For example if "number" is 2, then list will have that: finallist = [(a,b),(a,bp),(ap,b),(ap,bp)] or if "number" is 3, the list will have that: finallist = [(a,b,c),(a,b,cp),(a,bp,c),(a,bp,cp),(ap,b,c),(ap,b,cp),(ap,bp,c),(ap,bp,cp)].In this code, first I am separating variables as a ap b bp.. and after that I am making binary combination according to "number". Instead of making this step by hand, I thought maybe it could be possible to do it dynamically and I wrote the following code script but it did not give the reult that I want:

subList = [variables[n:n+number] for n in range(0, len(variables*2), number)]However it did not work!

For clarification:

This is my code for number 2:

number = 2 for variables in itertools.product([0, 1], repeat=(number*2)): # set of variables for a,ap,b,bp,c,cp like 000000 000001 000011.... a,ap,b,bp= variables[0],variables[1],variables[2],variables[3] finallist = [(a,b),(a,bp),(ap,b),(ap,bp)]THis is my code for number 3

number = 3 for variables in itertools.product([0, 1], repeat=(number*2)): # set of variables for a,ap,b,bp,c,cp like 000000 000001 000011.... a,ap,b,bp,c,cp= variables[0],variables[1],variables[2],variables[3],variables[4],variables[5] #giving value for a,ap,b,bp,c,cp finallist = [(a,b,c),(a,b,cp),(a,bp,c),(a,bp,cp),(ap,b,c),(ap,b,cp),(ap,bp,c),(ap,bp,cp)]THis is my code for number =4

number = 4 for variables in itertools.product([0, 1], repeat=(number*2)): # set of variables for a,ap,b,bp,c,cp like 000000 000001 000011.... a,ap,b,bp,c,cp,d,dp= variables[0],variables[1],variables[2],variables[3],variables[4],variables[5] ,variables[6],variables[7]#giving value for a,ap,b,bp,c,cp finallist = [(a,b,c,d),(a,b,c,dp),(a,b,cp,d),....]#I am not writingAnd I am looking for a way to create finallist dynamically