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 live in southern california. I was born in 1980. I do not have any kid. no compliacted dating. I am looking for ...
-
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...
-
There are some fun tools on Mac/PC which can help you on your studies, life and research. 1. Evernote: https://evernote.com/ To downl...
No comments:
Post a Comment