Recursive search in string by letter
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/13455761/python-cant-get-the-list-inside-the-function">Python - can’t get the list inside the function</a>  </p>
</blockquote>



<p>I wrote this code:</p>

<pre><code>answer=[]
def find_all(collection, item):
     import UserString
     collection = UserString.MutableString(collection)   # Turn the string to mutable
if len(collection)==0:
        return answer
if collection[len(collection)-1]==item:
        answer.insert(0, len(collection)-1)
del collection[len(collection)-1]
return find_all(collection,item)
</code></pre>

<p>It should give me an output list of location in the string/number depend on the number('item'). I tried many versions of it but still cant the list('answer=[]') inside the def. Whats the way to do it?</p>

<p>I should make this code work in recursion to practice recursion on python. with loops its much easier but I cant use it.</p>

<p>Thank you</p>
