title: All Permutations of a String in Python (Recursive)
body: <p>I need a kick in the head on this one. I have the following recursive function defined:</p>
  
  <pre><code>def perms(s):
    if(len(s)==1):
      return s
  
    res = ''
    for x in xrange(len(s)):
  
      res += s[x] + perms(s[0:x] + s[x+1:len(s)])
  
    return res + '\n'
  </code></pre>
  
  <p>perms("abc") currently returns:</p>
  
  <pre><code>abccb
  bacca
  cabba
  </code></pre>
  
  <p>The desired result is</p>
  
  <pre><code>abc
  acd
  bac
  bca
  cab
  cba
  </code></pre>
  
  <p><strong>Where am I going wrong here? How can I think about this differently to come up with the solution?</strong></p>
  
  <p><strong>Note:</strong> I am aware of the itertools function. I am trying to understand how to implement permutations recursively for my own learning. That is why I would prefer someone to point out what is wrong with my code, and how to think differently to solve it. Thanks!</p>