Choice1   Choice2   Choice3
A       1         5         9
B       2         6         10
C       3         7         11
D       4         8         12

How can i generate all possible combinations that include one choice for each row in python?

有帮助吗?

解决方案

You can try this to get the Cartesian product.

import itertools

rowlists = [[1,5,9],[2,6,10],[3,7,11],[4,8,12]]
for combination in itertools.product(*rowlists):
    print combination
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top