I have two dictionaries:
people = [
{
'name' : 'Ben',
'par_one' : ['a','b','c'],
'par_two' : [1,2,3,4,5]},
{
'name' : 'Jhon',
'par_one' : ['x','c','g','z'],
'par_two' : [3,6,9,]
}]
d2 = {
'name' : 'Ben',
'par_one' : 'random',
'par_two' : 5
}
I need to modify the value of d2 only if the value of par_one is "random", in this case, I want to overwrite "random" with the list in people that has the same key. The problem is that the list of people needs to have more dictionaries: so I have to find the correct dict (in the example case, the one with 'name' = 'Ben'), and then find the proper key and copy the value.
My expected output is:
final = {
'name' : 'Ben',
'par_one' : ['a','b','c'],
'par_two' : 5
}
thanks a lot!!