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

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad