s = '4824'

def partitions(s):
    yield [s]
if len(s) > 2:
    for i in range(len(s) - 1, 0, -1):
        for g in partitions(s[i:]):
            out = [s[:i]] + g
if not any([(len(out[i]) == len(out[i + 1]) and len(out[i]) == 1) for i in
    range(len(out) - 1)]):
    yield out
list(partitions(s))
python все комбинации подмножеств строки