from itertools import permutations print [' '.join(i) for i in permutations( code example
Example: python all permutations of a string
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms