removing dict entries by key using startswith
<p>I have a dict containing several entries beginning with '_'.
I want to get rid of all this entries using:</p>

<pre><code>for key in item:
    if key.startswith('_')
        del item[key]
</code></pre>

<p>But i get a syntax error on  <em>if key.startswith('_')</em></p>

<p>Is this method not allowed on key for dicts?</p>

<p>Your if statement is syntactically wrong. You need a : at the end of it like this</p>

<pre><code>for key in item:
    if key.startswith('_'):
        del item[key]
</code></pre>

python