Q. Write a program to check if a dictionary is contained in another dictionary.


e.g., if

d1 = {1:11, 2:12}
d2 = {1:11, 2:12, 3:13, 4:15}

Then d1 is contained in d2.

 

Answer = 

 

dic1 = eval(input("Enter first dictionary :-"))
dic2 = eval(input("Enter second dictionary :-"))

count = 0
for i in dic1 :
      for j in dic2 :
            if i == j :
                  count += 1

if count == len(dic1):
      print("Then d1 is contained in d2.")
else :
      print("Then d1 is not contained in d2.")


10 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Very much thank you ����������

    ReplyDelete
  2. in print statementyou should change D1 and D2 to dic1 and dic2...Hope this helps

    ReplyDelete
    Replies
    1. bro it does not matter it is a print statement

      Delete
  3. Bro iska output?

    ReplyDelete
  4. sanjeev teri maa ki chu

    ReplyDelete
  5. Output missing :-(

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post