Python:
Add value from one dictionary to the other dictionary.
I have two dictionaries, dic1 and dic2. They both have the same
keys. I want to add value from dic2 to dic1, so the output will
look like dic3:
dic1 = {
'AAA': ['A', '2000', 159.0 ],
'BBB': ['B', '2001', 826301.0],
'CCC': ['C', '2002', 2677971.0],
'DDD': ['D', '2003', 31217.0],
}
dic2 = {
'AAA': ['A', '2010', 999999.0],
'BBB': ['B', '2011', 100000.0],
'CCC': ['C', '2012', 120000.0 ],
'DDD': ['D', '2013', 1000000.0],
}
= I dic1 { 'AAA': ['A', '2000', 159.0 ], 'BBB': [ 'B', '2001', 826301.0], "CCC': ['c', '2002', 2677971.0], "DDD': ['D', '2003', 31217.0], } dic2 { AAA': [ 'A', '2010“, 999999.0], 'BBB': [ 'B', '2011', 100000.0], "CCC': ['C', '2012', 120000.0 ], "DDD': [ 'D', '2013', 1000000.0], } = I dic3 { 'AAA': [ 'A', '2000', 159.0, 'A', '2010', 999999.0], ‘BBB': [ 'B', '2001', 826301.0, 'B', '2011', 100000.0], ‘CCC': [ 'C', '2002', 2677971.0, 'C', '2012', 120000.0 ], *DDD': ['D', '2003', 31217.0, 'D', '2013', 1000000.0], BB
Python: Add value from one dictionary to the other dictionary. I have two dictionaries, dic1 and dic2. They both have th
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am