title: Understanding lists in python
body: <p>I am currently studying python for job interview purposes. I am trying to wrap my head around the following regarding lists in python:</p>
  
  <p>why do the following two pieces of code result in different outputs? </p>
  
  <pre><code>arr = [1,2,3,9,10,12]
  for i in arr:
    arr.remove(i)
  </code></pre>
  
  <p>This results in the list [2,9,12] however the following:</p>
  
  <pre><code>arr = [1,2,3,9,10,12]
  for i in list(arr):
    arr.remove(i)
  </code></pre>
  
  <p>This results in the desired empty list []. Can anyone explain why this is? Shouldn't iterating the list in the first manner also result in an empty list since remove() removes by item value? </p>
  
  <p>Disclaimer, I am testing this all out using Python3 via HackerRank.  </p>