Trying to filter a dictionary using list comprehension
<p>Using a single statement, print a dictionary containing only the atomic symbols and their corresponding weights for those elements in wts (my dictionary) which have only a single letter in their atomic symbols.  I.e., include 'H' but omit 'He'.  My dictionary is set up as <code>{'H':'1.00794','He':'4.002602','Li':'6.941','Be':'9.012182','B':'10.811','C':'12.0107','N':'14.0067','O':'15.9994'}</code></p>

<pre><code>[for element in wts if len(element) == 1]
</code></pre>

<p>I was thinking a list comprehension would would work but, how would i have it look only at the element symbol. This returns an error of :</p>

<pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "_sage_input_45.py", line 10, in &lt;module&gt;
    exec compile(u"print _support_.syseval(python, u'[for element in wts if len(element) == 1]', __SAGE_TMP_DIR__)" + '\n', '', 'single')
  File "", line 1, in &lt;module&gt;

  File "/sagenb/sage_install/sage-5.3-sage.math.washington.edu-x86_64-Linux/devel/sagenb-git/sagenb/misc/support.py", line 487, in syseval
    return system.eval(cmd, sage_globals, locals = sage_globals)
  File "/sagenb/sage_install/sage-5.3-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/misc/python.py", line 53, in eval
    eval(compile(s, '', 'exec'), globals, globals)
  File "", line 3
    [for element in wts if len(element) == 1]
       ^
SyntaxError: invalid syntax
</code></pre>
