title: What happens when you try to delete a list element while iterating over it
body: <p>I'm iterating a list as follows:</p>
  
  <pre><code>some_list = [1, 2, 3, 4]
  another_list = [1, 2, 3, 4]
  
  for idx, item in enumerate(some_list):
      del some_list[idx]
  
  for item in another_list:
      another_list.remove(item)
  </code></pre>
  
  <p>When I print out the contents of the lists</p>
  
  <pre><code>&gt;&gt;&gt; some_list
  [2, 4]
  &gt;&gt;&gt; another_list
  [2, 4]
  </code></pre>
  
  <p>I'm aware that Python doesn't support modifying a <code>list</code> while iterating over it and the right way is to iterate over copy of list instead. But I want to know what exactly happens behind the scenes i.e. Why is the output of the above snippet <code>[2, 4]</code>?</p>