title: Removing common values from two lists in python
body: <p>Hi let's say that I have two lists in python and I want to remove common values from both lists. A potential solution is:</p>
  
  <pre><code>x = [1, 2, 3, 4, 5, 6, 7, 8]
  y = [43, 3123, 543, 76, 879, 32, 14241, 342, 2, 3, 4]
  for i in x:
      if i in y:
          x.remove(i)
          y.remove(i)
  </code></pre>
  
  <p>it seems correct but it is not. The reason, I guess, is because by removing an item from the list the index continues to iterate. Therefore, for two common values in the lists where the values are near each other we will be missing the later values (the code will not iterate through it).
  The result would be:</p>
  
  <pre><code>&gt;&gt;&gt; x
  [1, 3, 5, 6, 8, 9, 10]
  &gt;&gt;&gt; y
  [43, 3123, 543, 76, 879, 32, 14241, 342, 3]
  </code></pre>
  
  <p>So we are missing the value <code>'3'</code>.</p>
  
  <p>Is the reason of that behaviour the one that I mentioned? or am I doing something else wrong?</p>