def split(s, n):

    def rec_split(i, s, n):
        ans = []
if n == 1:
    ans.append([s[i:]])
return ans
for j in range(i + 1, len(s)):
    head = s[i:j]
tails = rec_split(j, s, n - 1)
for tail in tails:
    ans.append([head] + tail)
return ans
return rec_split(0, s, n)
for e in split('foobar', 3):
    pass
Create possible combinations of specific size