title: for n in a list: del n
body: <p>When I loop over a list, the name that I give within the loop to the elements of the list apparently refers directly to each element in turn, as evidenced by:</p>
  <pre><code>&gt;&gt;&gt; a = [1, 2, 3]
  &gt;&gt;&gt; for n in a:
  ...     print n is a[a.index(n)]
  True
  True
  True
  </code></pre>
  <p>So why doesn't this seem to do anything?</p>
  <pre><code>&gt;&gt;&gt; for n in a: del n
  &gt;&gt;&gt; a
  [1, 2, 3]
  </code></pre>
  <p>If I try <code>del a[a.index(n)]</code>, I get wonky behavior, but at least it's behavior I can understand - every time I delete an element, I shorten the list, changing the indices of the other elements, so I end up deleting every other element of the list:</p>
  <pre><code>&gt;&gt;&gt; a = range(10)
  &gt;&gt;&gt; a
  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  &gt;&gt;&gt; for n in a: del a[a.index(n)]
  &gt;&gt;&gt; a
  [1, 3, 5, 7, 9]
  </code></pre>
  <p>Clearly I'm allowed to delete from the list while iterating. So what's going on when I try to <code>del n</code> inside the loop? Is anything being deleted?</p>