sa 12 cs chapter 2
10. Write a function called addDict(dict1, dict2) which computes the union of two dictionaries. It should return a new dictionary, with all the items in both its arguments (assumed to be dictionaries). If the same key appears in both arguments, feel free to pick a value from either.
# Code def addDict(dic1, dic2): new_dic = {} for i in dic1.keys(): # all the keys will be put into the new_dic new_dic[i] = dic1[i] for i in dic2.keys(): # keys common in both the dictionaries will have the values of dic2 in the new_dic new_dic[i] = dic2[i] return new_dic dic1 = {‘a’:1, ‘b’:2, ‘c’:3}