title: Inverting permutations in Python
body: <p>I'm new to programming, and I'm trying to write a Python function to find the inverse of a permutation on {1,2,3,...,n} using the following code:</p>
  
  <pre><code>def inv(str):
      result = []
      i = list(str).index(min(list(str)))
      while min(list(str)) &lt; len(list(str)) + 1:
          list(str)[i : i + 1] = [len(list(str)) + 1]
          result.append(i + 1)
      return result
  </code></pre>
  
  <p>However, when I try to use the function, <code>inv('&lt;mypermutation&gt;')</code> returns <code>[]</code>.  Am I missing something?  Is Python skipping over my while loop for some syntactical reason I don't understand?  None of my google and stackoverflow searches on topics I think of are returning anything helpful.</p>