title: All Permutations of a String in Python using Recursion
body: <p>I have this following Python code which returns a list of all the permutations of a given string using recursion. I tried my best to understand the working of the code but I am failed to do so. Can anyone please give me a breakdown of the code mentioned below?</p>
  
  <pre><code>def permute(s):
      out = []
  
      # Base Case
      if len(s) == 1:
          out = [s]
  
      else:
         # For every letter in string
         for i, let in enumerate(s):
             for perm in permute(s[:i] + s[i+1:]):
                  # Add it to output
                  out += [let + perm]
      return out
  
  permute('abc')
  ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']
  </code></pre>