Write a Program to combine two different dictionaries. While combining, if you find the same keys, you can add the values of these same keys. Output the new dictionary
Write a Program to combine two different dictionaries. While combining, if you find the same keys, you can add the values of these same keys. Output the new dictionary
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: medium
标签: interviewbit, python, topic-specific
参考答案摘要
We can use the Counter method from the collections module from collections import Counter d1 = {'key1': 50, 'key2': 100, 'key3':200} d2 = {'key1': 200, 'key2': 100, 'key4':300} new_dict = Counter(d1) ...
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。