title: Strange behavior by in-place modifying the list with bools during the for loop
body: <p>By solving a python exercise, I came across a strange behavior of for-loop that I do not understand.</p>
  
  <p><code>move_zeros(array)</code> should move all zeros of the array to its end. </p>
  
  <pre><code>def move_zeros(array):
          for x in array:
                  if  x == 0 and x is not False:
                          array.remove(x)
                          array.append(x)
  
          return array
  </code></pre>
  
  <p>It works just fine for arrays with all kind of item but if the array contains False the result is wrong:</p>
  
  <p><code>move_zeros([1,2,0,1,0,1,0,3,0,1]) =&gt; [ 1, 2, 1, 1, 3, 1, 0, 0, 0, 0 ]</code> (correct!)</p>
  
  <p>but</p>
  
  <p><code>move_zeros([0, 1, False, False]) =&gt; [1, False, 0, 0]</code> (incorrect!)</p>