Unable to delete all of a particular value from a list?
<p>I'm guessing that I am missing something that is glaringly obvious, but I cannot figure out why I cannot remove all of a particular value from the following list:</p>

<pre><code>&gt;&gt;&gt; t = [5.0, 5.0, 5.0, 4.0, 0.0, 5.0, 0.0, 3.0, 5.0, 5.0, 0.0, 0.0, 4.0, 5.0, 0.0, 5.0, 4.0, 5.0, 3.0, 3.0, 5.0, 5.0, 5.0, 5.0]
&gt;&gt;&gt; for x in t:
    if x == 0.0:
        t.remove(x)


&gt;&gt;&gt; print t
[5.0, 5.0, 5.0, 4.0, 5.0, 3.0, 5.0, 5.0, 4.0, 5.0, 0.0, 5.0, 4.0, 5.0, 3.0, 3.0, 5.0, 5.0, 5.0, 5.0]
</code></pre>

<p>I would expect all <code>0.0</code> elements to be removed from t, but one in the middle remains. Coming at the problem from a slightly different angle, I achieved the same results:</p>

<pre><code>&gt;&gt;&gt; print t
[5.0, 5.0, 5.0, 4.0, 0.0, 5.0, 0.0, 3.0, 5.0, 5.0, 0.0, 0.0, 4.0, 5.0, 0.0, 5.0, 4.0, 5.0, 3.0, 3.0, 5.0, 5.0, 5.0, 5.0]
&gt;&gt;&gt; for i, j in enumerate(t):
    if j == 0.0:
        del t[i]

&gt;&gt;&gt; print t
[5.0, 5.0, 5.0, 4.0, 5.0, 3.0, 5.0, 5.0, 0.0, 4.0, 5.0, 5.0, 4.0, 5.0, 3.0, 3.0, 5.0, 5.0, 5.0, 5.0]
</code></pre>

<p>Can anyone point me to what must be an obvious mistake?</p>
