Write a Python program to match key values in two dictionaries
Sample dictionary: {'key1': 1, 'key2': 3, 'key3': 2}, {'key1': 1, 'key2': 2}
Expected output: key1: 1 is present in both x and y
class Solution:
def two1(self, dic1,dic2):
dic3={}
for key in dic1.keys():
if key in dic2.keys() and dic1[key]==dic2[key]:
dic3[key]=dic1[key]
return(dic3)
kk=Solution()
if __name__=="__main__":
print(kk.two1({"a":1,"b":5,"i":9,"o":3},{"a":1,"b":5,"o":3,"t":19,"u":100}))
I wrote about the solutions to some problems I found from programming and data analytics. They may help you on your work. Thank you.
ezoic
Wednesday, March 8, 2017
Subscribe to:
Post Comments (Atom)
looking for a man
I am a mid aged woman. I was born in 1980. I do not have any kid. no complicated dating before . I am looking for a man here for marriage...
-
I tried to commit script to bitbucket using sourcetree. I first cloned from bitbucket using SSH, and I got an error, "authentication ...
-
https://github.com/boto/boto3/issues/134 import boto3 import botocore client = boto3.client('s3') result = client.list_obje...
-
Previously, I wanted to install "script" on Atom to run PHP. And there was some problem, like the firewall. So I tried atom-runner...
No comments:
Post a Comment