title: How to update list of dictionaries using another list of dictionaries?
body: <p>I have two lists as shown below. I want to update the new list using the old list. The criteria to update the new list are matching values for <code>name</code> in old list. What is the best way to do it?</p>
  
  <p><strong>Input</strong> </p>
  
  <pre><code>old_list = [{'age': 35, 'name': 'james'}, {'age': 42, 'name': 'bob'}]
  
  new_list = [{'name': 'peter'}, {'name': 'james'}, {'age': 50, 'name': 'bob'}]
  </code></pre>
  
  <p><strong>Expected Output</strong></p>
  
  <pre><code>[{'name': 'peter'}, {'age': 35, 'name': 'james'}, {'age': 42, 'name': 'bob'}]
  </code></pre>
  
  <p><strong>Edit: Adding my solution</strong></p>
  
  <p>One solution that I know to solve this using multiple loops and if conditions. It is not the compete solution as I need to handle multiple scenarios like where key is not present etc.</p>
  
  <pre><code>for x in new_col_list:
      for y in old_col_list:
          if x['name'] == y['name']:
              x['age'] = y['age']
              continue
  
  print new_col_list
  </code></pre>