title: Python: Removing list element while iterating over list
body: <p>I'm iterating over a list of elements in Python, do some action on it, and then remove them if they meet certain criteria.</p>
  
  <pre><code>for element in somelist:
      do_action(element)
      if check(element):
          remove_element_from_list
  </code></pre>
  
  <p>What should I use in place of remove_element?
  I have seen similar questions asked, but notice the presence of the do_action part that is to be executed for all elements and thus eliminates the solution of using filters.</p>