title: Finding the indices of matching elements in list in Python
body: <p>I have a long list of float numbers ranging from 1 to 5, called "average", and I want to return the list of indices for elements that are smaller than a or larger than b</p>
  
  <pre><code>def find(lst,a,b):
      result = []
      for x in lst:
          if x&lt;a or x&gt;b:
              i = lst.index(x)
              result.append(i)
      return result
  
  matches = find(average,2,4)
  </code></pre>
  
  <p>But surprisingly, the output for "matches" has a lot of repetitions in it, e.g. <code>[2, 2, 10, 2, 2, 2, 19, 2, 10, 2, 2, 42, 2, 2, 10, 2, 2, 2, 10, 2, 2, ...]</code>. </p>
  
  <p>Why is this happening?</p>