def segment(word):

    def sub(w):
        if len(w) == 0:
            yield []
for i in range(1, min(4, len(w) + 1)):
    for s in sub(w[i:]):
        yield [''.join(w[:i])] + s
return list(sub(word))

def str_segment(word):
    return [' '.join(w) for w in segment(word)]
Прочитайте все возможные последовательные подстроки в Python