Suppose you are given two dictionaries. Now create a new dictionary "marks", merging the two dictionaries, so that the original two dictionaries remain unchanged. Note: You can use dictionary functions. =================================================================== Given: {'Harry':15, 'Draco':8, 'Nevil':19} {'Ginie':18, 'Luna': 14} Output: {'Harry': 15, 'Draco': 8, 'Nevil': 19, 'Ginie': 18, 'Luna': 14} =================================================================== Given: {'A':90, 'B': 0} {'C':50} Output: {'A': 90, 'B': 0, 'C': 50}
dict_1 = {'Harry':15, 'Draco':8, 'Nevil':19}
dict_2 = {'Ginie':18, 'Luna': 14}
output_dict = {**dict_1, **dict_2}
print(output_dict)
Comments
Leave a comment