This is an extension of this question. And this seems to show an example of appending to an array, not adding another value to a sub-dict.
dict_1 = {a: {price: 4000}, b: {price: 14000} }
dict_2 = {a: {discount: 0100}, b: {discount: 0400} }
dict_3 = {a: {amount: 41}, b: {amount: 522} }
I would like to merge them to be:
merged_dict: { a: {
price: 4000,
discount: 0100,
amount: 41
},
b: {
price: 14000,
discount: 0400,
amount: 522
}
}
How to achieve that? And how would that be if there was en even longer list of dictionaries to merge? The dictionaries will always have the same keys (a, b).
I tried doing the same as in the first hyperlink but the .items()
seem to make it unscalable.