Programming Examples
Python program that lists the over lapping keys of the two dictionaries if a key of d1 is also a key of d2 the list it
Given two dictionaries say d1 and d2
Write a program that lists the over lapping keys of the two dictionaries if a key of d1 is also a key of d2 , the list it .
Solution
d1 = eval(input("enter first dictionary = "))
d2 = eval(input("enter second dictionary = "))
lst1 = (d1.keys() )
lst2 = (d2.keys() )
lst = [ ]
for i in lst1 :
for j in lst2 :
if i == j :
lst += [ i ]
print("over lapping keys are ",lst)
Output/ Explanation: