(Jan-27-2021, 07:54 PM)bowlofred Wrote: My variables
was just a single list. I'm not completely sure, but maybe you want to run it for each of the groups in your product? Like this?
from itertools import product
from more_itertools import grouper
import string
# create the "data"
number = 2
for variables in product([0, 1], repeat=(number*2)):
print(f"Running for variables = {variables}")
groups = grouper(variables, 2)
finallist = product(*groups)
print(list(finallist))
Output:
Running for variables = (0, 0, 0, 0)
[(0, 0), (0, 0), (0, 0), (0, 0)]
Running for variables = (0, 0, 0, 1)
[(0, 0), (0, 1), (0, 0), (0, 1)]
Running for variables = (0, 0, 1, 0)
[(0, 1), (0, 0), (0, 1), (0, 0)]
Running for variables = (0, 0, 1, 1)
[(0, 1), (0, 1), (0, 1), (0, 1)]
...
Exactly but still I have the same error??
Error:
groups = more_itertools.grouper(variables, 2)
File "/usr/lib/python3/dist-packages/more_itertools/recipes.py", line 295, in grouper
args = [iter(iterable)] * n
TypeError: 'int' object is not iterable
This is working for you but not working for me. This is quite interesting!