title: Why doesn't .remove inside for loop remove all instances from list in Python?
body: <p>When typing the title of my question, Stack Overflow provided a link to this question whose title does admittedly match my question almost exactly:</p>
  <p><a href="https://stackoverflow.com/questions/24565327/calling-remove-inside-for-loop-doesnt-remove-all-elements">Calling `.remove()` inside `for` loop doesn&#39;t remove all elements</a></p>
  <p>However, that question is about jQuery, which I'd never even heard of before, and the sample code seems to be a lot more complicated than mine. Furthermore, the accepted answer to that question seems to be saying that the code sweeps through the list multiple times and crashes the last time; I don't think that's the case for my example.</p>
  <pre><code>def f(x):
      for num in x:
          if num==np.NINF:
              x.remove(num)
      return x
  print(f([0,np.NINF,np.NINF]))
  </code></pre>
  <p>This returns [0, -inf] instead of the expected [0]. Why?</p>