title: Create a new list of dictionaries within a new dictionary in Python
body: <p>I have a list of dictionaries and need to create a new one that contains new keys and also keys&amp;values from my original dictionary. One of the keys will have to contain a list of dictionaries (those would be the values from original dictionary)
  My data looks like the following:</p>
  
  <pre><code>data = [{'CloseDate': '2020-05-01',
    'OpportunityID': '1',
    'CustomerID': '10'},
   {'CloseDate': '2020-07-31',
    'OpportunityID': '2',
    'CustomerID': '11'}]
  </code></pre>
  
  <p>I want my new list of dicts look like this:</p>
  
  <pre><code>new_data = [{'id': '39',
             'Query': [{'records': '40', 'Order Name': '1', 'CustomerID': '10'}]},
             {'id': '39',
             'Query': [{'records': '40', 'Order Name': '2', 'CustomerID': '11'}]}]
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code>new_data = []
  
  for item in data: 
      params_dict = {}
      params_dict["id"] = "39"
      params_dict["Query"] = []
      # push new_dicts in params_dict
      new_dict = {}
      new_dict["records"] = "40"
      new_dict["Order Name"] = data["OpportunityID"]
      params_dict.append(new_dict)
      new_data.append(params_dict)
  </code></pre>
  
  <p>Error: <code>TypeError: list indices must be integers or slices, not str</code></p>