title: Python: An elegant way to delete empty lists from Python dictionary
body: <p>I have a dictionary as:</p>
  
  <pre><code>default = {'a': ['alpha'], 'b': ['beta','gamma'], 'g': []}
  </code></pre>
  
  <p>I wish to eliminate the empty values as:</p>
  
  <pre><code>default = {'a': ['alpha'], 'b': ['beta','gamma']}
  </code></pre>
  
  <p>I wrote a function (following an example found on the web)</p>
  
  <pre><code>def remove_empty_keys(d):
      for k in d.keys():
          try:
              if len(d[k]) &lt; 1:
                  del[k]
          except:
              pass
          return(d)
  </code></pre>
  
  <p>I have the following questions:</p>
  
  <p>1- I didn't find the mistake why it always returns following - </p>
  
  <pre><code>remove_empty_keys(default)
   {'a': ['alpha'], 'b': ['beta'], 'g': []}
  </code></pre>
  
  <p>2- Is there a built-in function to eliminate/delete Null/None/empty values from Python dictionary without creating a copy of the original dictionary?</p>