I have two lists of items
list1 = [
{
"id_0":356,
"name":"India",
"key1":150
},
{
"id_0":356,
"name":"India",
"key2":200
},
{
"id_0":748,
"name":"Swaziland",
"key1":140
},
{
"id_0":748,
"name":"Swaziland",
"key2":180
}
]
I am attempting to identify the matching id_0
in the list and combine the duplicate item's key2
and its value.
The desired outcome is as follows:
list1 = [
{
"id_0":356,
"name":"India",
"key1":150,
"key2":200
},
{
"id_0":748,
"name":"Swaziland",
"key1":140,
"key2":180
}
]
What is the process to locate the duplicate value and merge the repeated key-value pair in the list?