How to remove multiple items from a list in just one statement?
<p>In python, I know how to remove items from a list:</p>
<pre><code>item_list = ['item', 5, 'foo', 3.14, True]
item_list.remove('item')
item_list.remove(5)
</code></pre>
<p>The above code removes the values 5 and 'item' from <code>item_list</code>.
But when there is a lot of stuff to remove, I have to write many lines of:</p>
<pre><code>item_list.remove(&quot;something_to_remove&quot;)
</code></pre>
<p>If I know the index of what I am removing, I use:</p>
<pre><code>del item_list[x]
</code></pre>
<p>where x is the index of the item I want to remove.</p>
<p>If I know the index of all of the numbers that I want to remove, I'll use some sort of loop to <code>del</code> the items at the indices.</p>
<p>But what if I don't know the indices of the items I want to remove?</p>
<p>I tried <code>item_list.remove('item', 'foo')</code>, but I got an error saying that <code>remove</code> only takes one argument.</p>
<p>Is there a way to remove multiple items from a list in a single statement?</p>
<p>P.S. I've used <code>del</code> and <code>remove</code>. Can someone explain the difference between these two, or are they the same?</p>