I have found the following code from: Finding all possible permutations of a given string in python
it works nicely but I don\'t understand part of the loop that I\'ve hi