title: compare 2 list of dicts containing different keys and update if match found
body: <p>I have two list of dictionaries containing different keys. I know the keys that I want to compare. If there is a match in their values, I want to update the dict, from the list, been compared with the value of a key from the matching dict in the second list of dicts. I need to compare multiple keys at a time. Note: the number of items in each dict and dicts in each list are much longer than what I have in my example</p>
  <pre><code>list1 = [{'c':4, 'd':'er3', 'e':'egg'}, {'c':1, 'd':'room1', 'e':'soup'}, {'c':a8, 'd':'er5', 'e':'rice'}]
  list2 = [{'s':4, 'loc':'sw', food:'soup', t:'9pm'}, {'s':2, 'loc':'er5', food:'egg', t:'12am'}, {'s':1, 'loc':'se', food:'soup', t:'4pm'}, {'s':a7, 'loc':'n', food:'unknown', t:'1am'}]
  </code></pre>
  <p>desired result</p>
  <pre><code>result = [{'c':4, 'd':'er3', 'e':'egg', 'time':'NA'}, {'c':1, 'd':'room1', 'e':'soup', time:'4pm'}, {'c':a8, 'd':'er5', 'e':'rice', 'time':'NA'}}
  </code></pre>
  <p>I compared dict keys c and s and keys e and food. In this case only the second dict in list1 matched so I updated the matched dict with a key time and inserted the value of key t from the dict. For the non matched dict, I still entered a key time but set it to NA.</p>
  <p>Here is what I have so far:</p>
  <pre><code>for mydict in list1:
      mydict['time'] = [x.get('t') for x in list2 if any([x.get('s') == mydict.get('c') and x.get('food')== mydict.get('e') for x in list2])]
      print(mydict)
  </code></pre>
  <p>when I print, I get the result but with multiple NA's like this:</p>
  <pre><code>{'c':1, 'd':'room1', 'e':'soup', time: ['4pm', 'NA','NA','NA','NA','NA','NA'}
  </code></pre>
  <p>Any help will be appreciated. How do I format the long blocks to avoid scrolling?</p>