# Counting combinations # nCk = n! / (k!(n-k)!) from math import comb >>> comb(10,3) 120
import itertools stuff = [1, 2, 3] for L in range(len(stuff) + 1): for subset in itertools.combinations(stuff, L): print(subset)