title: Delete dictionary values if they are present in a set
body: <p>I have a Python set</p>
  <pre><code>A = {34, 4, 7, 39, 40, 13, 18, 20}
  </code></pre>
  <p>and a dictionary</p>
  <pre><code>B = {4: [6, 34, 39], 7: [18, 34], 13: [6, 18, 34], 18: [7, 13], 
       20: [31, 47], 34: [4, 7, 13], 39: [4, 8], 40: [15, 43]}
  </code></pre>
  <p>I want to create a new dictionary C such that if any of the values in B contains a number in A, then they must be removed from the corresponding value list. Keys should be unaffected.</p>
  <p>For example, the desired output that I am looking for is:</p>
  <pre><code>C = {4: [6], 7: [], 13: [6], 18: [], 20: [31, 47], 34: [], 39: [8]}
  </code></pre>
  <p>I tried to solve this using the following code:</p>
  <pre><code>C = {}
  for key, value in B_mod.items():
      if value in A:
          C[key] = value
  print(&quot;C is:&quot;, C)
  </code></pre>
  <p>The output that I am getting is as follows:</p>
  <pre><code>C is: {7: 18, 18: 7, 34: 4, 39: 4}
  </code></pre>
  <p>Clearly, it is not working.</p>
  <p>*Please note that <code>B_mod</code> means that I am unlisting the list in values of dictionary B using the code:</p>
  <pre><code>B_mod = {k:v[0] for k,v in B.items()} # Unlisitng the values of dictionary B
  </code></pre>
  <p>I did this because I could not iterate through lists as values in B.*</p>
  <p>Any help to get C?</p>