Thorsten Kampe writes:
> [((1, 4), 7), ((1, 4), 8), ((1, 5), 7), ((1, 5), 8), ((2, 4), 7), ((2,
> 4), 8), ((2, 5), 7), ((2, 5), 8)]
[...]
> What's the best way to pre-process the arguments to "itertools.product"
> or to post-process the result of "itertools.product" to get what I
> want?!
P
Thorsten Kampe wrote:
Hi,
is there a way to make itertools.product generate triples instead of
pairs from two lists?
For example:
list1 = [1, 2]; list2 = [4, 5]; list3 = [7, 8]
from itertools import product
list(product(list1, list2, list3))
[(1, 4, 7), (1, 4, 8), (1, 5, 7), (1, 5, 8), (2, 4
On Jan 25, 3:12�pm, Thorsten Kampe wrote:
> Hi,
>
> is there a way to make itertools.product generate triples instead of
> pairs from two lists?
>
> For example:>>> list1 = [1, 2]; list2 = [4, 5]; list3 = [7, 8]
> >>> from itertools import product
> >>> list(product(list1, list2, list3))
>
> [(1,
Hi,
is there a way to make itertools.product generate triples instead of
pairs from two lists?
For example:
>>> list1 = [1, 2]; list2 = [4, 5]; list3 = [7, 8]
>>> from itertools import product
>>> list(product(list1, list2, list3))
[(1, 4, 7), (1, 4, 8), (1, 5, 7), (1, 5, 8), (2, 4, 7), (2, 4, 8