title: Recursive implementation of permutations in Python
body: <p>I apologize that there have already been many posts about this problem. However, I am having a hard time seeing where I am going wrong in my own implementation. So I am trying to write a function that takes in a string and returns all of it's possible permutations in the form of a list. </p>
  
  <p>Theoretically it should look like this: </p>
  
  <p>allPermutations("abc...z") = [a + allPermutations(b,c,...z), b + allPermutations(a,c...z)...]</p>
  
  <p>My current implementation, when tested on the String, "Hello", outputs a bunch of duplicate permutations. Can anyone help me see where I am going wrong. I appreciate your assistance!</p>
  
  <p>Here is the Code:</p>
  
  <pre><code>def allPermutations(strng):
      if len(strng) ==1:
          return [strng]
      perm_list = []
      for i in strng:
          smallerStr = strng.replace(i,"",1)
          z = allPermutations(smallerStr)
  
          for t in z:
              perm_list.append(i+t)        
      return perm_list
  </code></pre>