title: Python: remove odd number from a list
body: <p>I wrote a function to remove odd number from a list, like that:</p>
  
  <pre><code>def remove_odd(l):
      for i in l:
          if i % 2 != 0:
              l.remove(i)
      print l
      return l
  
  remove_odd([4,5,4])
  remove_odd([4,5,4,7,9,11])
  remove_odd([4,5,4,7,9,11,12,13])
  </code></pre>
  
  <p>It returns:</p>
  
  <pre><code>[4, 4]
  [4, 4, 9]
  [4, 4, 9, 12]
  </code></pre>
  
  <p>-> wrong </p>
  
  <p>but when I change to remove even number:</p>
  
  <pre><code>def remove_even(l):
      for i in l:
          if i % 2 == 0:
              l.remove(i)
      print l
      return l
  
  remove_even([4,5,4])
  remove_even([4,5,4,7,9,11])
  remove_even([4,5,4,7,9,11,12,13])
  </code></pre>
  
  <p>The answer is OK:</p>
  
  <pre><code>[5]
  [5, 7, 9, 11]
  [5, 7, 9, 11, 13]
  </code></pre>
  
  <p>What is wrong with the remove_odd() func?
  I know people usually create the second list inside the func then append even number to that list, but can we solve this exercise with list.remove() ?</p>
  
  <p>Thank you!</p>