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:

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad