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

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad