Write a program that prints dictionaries having key of the first dictionary and value of the second dictionary


Topic: Write a program that prints dictionaries having key of the first dictionary and value of the second dictionary

Solution

test_dict1 = {"tsai" : 20, "is" : 36, "best" : 100} 
test_dict2 = {"tsai2" : 26, "is2" : 19, "best2" : 70} 
keys1 = list(test_dict1.keys()) 
vals2 = list(test_dict2.values()) 
res = dict() 
for idx in range(len(keys1)): 
	res[keys1[idx]] = vals2[idx] 
print("Mapped dictionary : " + str(res))



List all Python Programs