I have two lists of dictionaries list_1
and list_2
. I want to update each dictionary in list_2
with the proper value(s) from the corresponding dictionary from list_1
based on a match key values.
I am finding it difficult to iterate over dictionaries in a list. Any help would be appreciated.
INPUT:
list_1 = [
{'time': '2022-02-22T19:36:48.343000Z', 'name': 'oracle1', 'qid': '100172', 'utep': 'UEXC00345345'},
{'time': '2022-02-22T19:36:48.343000Z', 'name': 'oracle2', 'qid': '105134', 'utep': 'UEXC1231231'}
]
list_2 = [
{'time': '2021-03-02T23:31:46.495993Z', 'server_id': '100172', 'name': 'apache1'},
{'time': '2021-03-02T23:31:46.516669Z', 'server_id': '100178', 'name': 'apache2'}
]
My code so far:
for k in list1:
for Q in list2:
if (qid == server_id):
list2.insert(list1[utep]