title: Filter list of dict based on values from another dict
body: <p>I have a list of dictionaries <code>list_of_dict</code>, a set of keys <code>set_of_keys</code> and another dictionary <code>dict_to_compare</code>. </p>
  
  <p>I need to filter the list of dicts if the values of any two of the three possible keys matches the values from <code>dict_to_compare</code>.</p>
  
  <p><strong>Input:</strong></p>
  
  <pre><code>set_of_keys = {'val1', 'val2', 'val3'}
  
  dict_to_compare = {'k1': 'val1', 'k2': 'val2','k3':'val6'}
  
  list_of_dict = [
          {'k1': 'val1', 'k2': 'val2', 'k3':'val3'},
          {'k1': 'val4', 'k2': 'val5', 'k3':'val6'},
          {'k1': 'val7', 'k2': 'val8', 'k3':'val9'}
  ]
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code> out = [{'k1': 'val1', 'k2': 'val2', 'k3': 'val3'}] #First element from list
  </code></pre>
  
  <ul>
  <li>All elements in <code>list_of_dicts</code> have same keys.</li>
  <li><code>dict_to_compare</code> also have same keys as elements of <code>list_of_dicts</code>.</li>
  <li>Multiple elements from <code>list_of_dicts</code> can be matched.</li>
  <li>Values against any combination of two keys should be matched not all three.</li>
  </ul>
  
  <p>I tried doing this by explicitly specifying bunch of <code>if</code> <code>elif</code> conditions. But the problem is set of keys is really huge. Is there a better way to solve this?</p>
  
  <p>Thanks</p>