Remove all occurences of a value from a Python list
<p>In Python <code>remove()</code> will remove the first occurrence of value in a list.</p>

<p>How to remove all occurrences of a value from a list, without sorting the list?</p>

<p>This is what I have in mind.</p>

<pre><code>&gt;&gt;&gt; x = [1, 2, 3, 4, 2, 2, 3]
&gt;&gt;&gt; def remove_values_from_list(the_list, val):
        while val in the_list:
            the_list.remove(val)
&gt;&gt;&gt; remove_values_from_list(x, 2)
&gt;&gt;&gt; x
[1, 3, 4, 3]
</code></pre>
