Это декартово произведение , и вы можете использовать itertools.product
для его вычисления:
a = [0, 1]
b = [2, 3]
c = [4, 5]
d = [6, 7]
e = [8, 9]
for subset in product(a, b, c, d, e):
print(subset)
выход
(0, 2, 4, 6, 8)
(0, 2, 4, 6, 9)
(0, 2, 4, 7, 8)
(0, 2, 4, 7, 9)
(0, 2, 5, 6, 8)
(0, 2, 5, 6, 9)
(0, 2, 5, 7, 8)
(0, 2, 5, 7, 9)
(0, 3, 4, 6, 8)
(0, 3, 4, 6, 9)
(0, 3, 4, 7, 8)
(0, 3, 4, 7, 9)
(0, 3, 5, 6, 8)
(0, 3, 5, 6, 9)
(0, 3, 5, 7, 8)
(0, 3, 5, 7, 9)
(1, 2, 4, 6, 8)
(1, 2, 4, 6, 9)
(1, 2, 4, 7, 8)
(1, 2, 4, 7, 9)
(1, 2, 5, 6, 8)
(1, 2, 5, 6, 9)
(1, 2, 5, 7, 8)
(1, 2, 5, 7, 9)
(1, 3, 4, 6, 8)
(1, 3, 4, 6, 9)
(1, 3, 4, 7, 8)
(1, 3, 4, 7, 9)
(1, 3, 5, 6, 8)
(1, 3, 5, 6, 9)
(1, 3, 5, 7, 8)
(1, 3, 5, 7, 9)