I am learning backtracking and recursion and I am stuck at an algorithm for printing all the permutations of a string. I solved it using the bell algorithm for permutation b
def perms(s): if len(s) < 1: return [s] ps = [] for i in range(0, len(s)): head, tail = s[i], s[0:i] + s[i + 1:] ps.extend([head + tailp for tailp in perms(tail)]) return ps