title: how to correctly modify the iterator of a loop in python from within the loop
body: <p>what I basically need is to check every element of a list and if some criteria fit I want to remove it from the list.</p>
  
  <p>So for example let's say that</p>
  
  <pre><code>list=['a','b','c','d','e']
  </code></pre>
  
  <p>I basically want to write (in principle and not the actual code I try to implement)</p>
  
  <p>If an element of the list is 'b' or 'c' remove it from the list and take the next.</p>
  
  <p>But</p>
  
  <pre><code>for s in list:
      if s=='b' or s=='c':
          list.remove(s)
  </code></pre>
  
  <p>fails because when 'b' is removed the loop takes 'd' and not 'c' as the next element. So is there a way to do that faster than storing the elements in a separate list and removing them afterwards?</p>
  
  <p>Thanks.</p>