[Solved] Getting all possible combination for [1,0] with length 3 [0,0,0] to [1,1,1]


You’re looking for a Cartesian product, not a combination or permutation of [0, 1]. For that, you can use itertools.product.

from itertools import product

items = [0, 1]

for item in product(items, repeat=3):
    print(item)

This produces the output you’re looking for (albeit in a slightly different order):

(0, 0, 0)
(0, 0, 1)
(0, 1, 0)
(0, 1, 1)
(1, 0, 0)
(1, 0, 1)
(1, 1, 0)
(1, 1, 1)

solved Getting all possible combination for [1,0] with length 3 [0,0,0] to [1,1,1]