Jan-27-2021, 08:38 PM
Show the entire code (including imports). Your code seems to work for me....
import itertools import more_itertools 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,c,cp= variables[0],variables[1],variables[2],hvariables[3] #giving value for a,ap,b,bp,c,cp #nlist = [(a,b),(a,bp),(ap,b),(ap,bp)] #binary combination of a,ap,b,bp,c,cp groups = more_itertools.grouper(variables, 2) finallist = itertools.product(*groups) print(list(finallist))
Output:[(0, 0), (0, 0), (0, 0), (0, 0)]
[(0, 0), (0, 1), (0, 0), (0, 1)]
[(0, 1), (0, 0), (0, 1), (0, 0)]
[(0, 1), (0, 1), (0, 1), (0, 1)]
[(0, 0), (0, 0), (1, 0), (1, 0)]
[(0, 0), (0, 1), (1, 0), (1, 1)]
[(0, 1), (0, 0), (1, 1), (1, 0)]
[(0, 1), (0, 1), (1, 1), (1, 1)]
[(1, 0), (1, 0), (0, 0), (0, 0)]
[(1, 0), (1, 1), (0, 0), (0, 1)]
[(1, 1), (1, 0), (0, 1), (0, 0)]
[(1, 1), (1, 1), (0, 1), (0, 1)]
[(1, 0), (1, 0), (1, 0), (1, 0)]
[(1, 0), (1, 1), (1, 0), (1, 1)]
[(1, 1), (1, 0), (1, 1), (1, 0)]
[(1, 1), (1, 1), (1, 1), (1, 1)]