title: How to solve dictionary changed size during iteration error?
body: <p>I want pop out all the large values and its keys in a dictionary, and keep the smallest. Here is the part of my program</p>
  
  <pre><code>for key,value in dictionary.items():
      for key1, value1 in dictionary.items(): 
              if key1!= key and value &gt; value1:
                  dictionary.pop(key)             
      print (dictionary)  
  </code></pre>
  
  <p>Which results in</p>
  
  <pre><code>RuntimeError: dictionary changed size during iteration    
  </code></pre>
  
  <p>How can I avoid this error?</p>