def permutate_all_substrings(text):
    permutations = []
for length in range(1, len(text) + 1):
    for permutation in itertools.permutations(text, length):
        permutations.append(''.join(permutation))
return permutations
Python permutations including substrings