Python: Add value from one dictionary to the other dictionary. I have two dictionaries, dic1 and dic2. They both have th

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Python: Add value from one dictionary to the other dictionary. I have two dictionaries, dic1 and dic2. They both have th

Post by answerhappygod »

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],
}
Python Add Value From One Dictionary To The Other Dictionary I Have Two Dictionaries Dic1 And Dic2 They Both Have Th 1
Python Add Value From One Dictionary To The Other Dictionary I Have Two Dictionaries Dic1 And Dic2 They Both Have Th 1 (258.51 KiB) Viewed 15 times
= 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply