why a for loop skip the first element after the list in the for loop has been changed?
<p>I intended to remove the elements with <code>'0'</code> in the end or only with <code>'0'</code>, and my codes are:</p>

<pre><code>s = ['a0', 'b0', '0', 'c', 'd']
for x in s:
    if x[-1] == '0' or x == '0':
        s.remove(x)

s #result
['b0', 'c', 'd']
</code></pre>

<p>When I debug, I found that after 'a0' is removed, the <code>s</code> becomes <code>['b0', '0', 'c', 'd']</code>, then as I thought, x will be <code>'b0'</code>, but it turn out to be <code>'0'</code>, so it skipps the <code>'b0'</code>, I am wondering the reason behind that and how to fix it?</p>