title: How to avoid "RuntimeError: dictionary changed size during iteration" error?
body: <p>I have checked all of the other questions with the same error yet found no helpful solution =/</p>
  <p>I have a dictionary of lists:</p>
  <pre><code>d = {'a': [1], 'b': [1, 2], 'c': [], 'd':[]}
  </code></pre>
  <p>in which some of the values are empty. At the end of creating these lists, I want to remove these empty lists before returning my dictionary. Current I am attempting to do this as follows:</p>
  <pre><code>for i in d:
      if not d[i]:
          d.pop(i)
  </code></pre>
  <p>however, this is giving me the runtime error. I am aware that you cannot add/remove elements in a dictionary while iterating through it...what would be a way around this then?</p>
  <hr />
  <p><sub>See <a href="https://stackoverflow.com/questions/6777485/">Modifying a Python dict while iterating over it</a> for citations that this can cause problems, and why.</sub></p>