You can use itertools
to calculate the products for you and can use the *
operator to convert your list into arguments for the itertools.product()
function.
import itertools
a = [1]
b = [2,3]
c = [4,5,6]
args = [a,b,c]
for combination in itertools.product(*args):
print combination
Output is
(1, 2, 4)
(1, 2, 5)
(1, 2, 6)
(1, 3, 4)
(1, 3, 5)
(1, 3, 6)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…