title: What is the best way to remove a dictionary item by value in python?
body: <p>I wonder if there is <em>simple</em> way to remove <em>one</em> or <em>more</em> dictionary element(s) from a python dictionary <em>by value</em>.</p>
  
  <p>We have a dictionary called <code>myDict</code>:</p>
  
  <pre><code>myDict = {1:"egg", "Answer":42, 8:14, "foo":42}
  </code></pre>
  
  <p>and want to <em>remove</em> all items which <em>values</em> are equal to <code>42</code>.</p>
  
  <p>Implementation suggestion:</p>
  
  <ol>
  <li><p>Get a list of all keys of a certain value in <code>myDict</code><br />(See for instance <a href="https://stackoverflow.com/questions/8023306/get-key-by-value-in-dictionary">get key by value in dictionary</a>.)</p></li>
  <li><p>Delete this dict element or elements (based on the found keys) from <code>myDict</code><br />(For more information, see <a href="https://stackoverflow.com/questions/5844672/delete-an-element-from-a-dictionary">Delete an element from a dictionary</a>.)</p></li>
  </ol>
  
  <p>So, what do you think now is the <strong>most elegant</strong> and <strong>most “pythonic”</strong> way to implement this problem in Python?</p>