title: Loop problem while iterating through a list and removing recurring elements
body: <p>I want to iterate through a list, and remove the items that count more than once, so they don't get printed repeatedly by the for loop. </p>
  
  <p>However, some items appearing only one time in the list seem to get affected too by this, and I can't figure out why. </p>
  
  <p>Any input would be greatly appreciated. </p>
  
  <p>Example Output: </p>
  
  <pre><code>listy = [2,2,1,3,4,2,1,2,3,4,5]
  for i in listy:
    if listy.count(i)&gt;1:
      print i, listy.count(i)
      while i in listy: listy.remove(i)
    else:
      print i, listy.count(i)
  </code></pre>
  
  <p>Outputs: </p>
  
  <pre><code> 2 4
   3 2
   1 2
  </code></pre>
  
  <p>thus ignoring completely 4 and 5.       </p>