-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathdict_interdiff.py
36 lines (30 loc) · 911 Bytes
/
dict_interdiff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def dict_interdiff(d1,d2):
'''
:param d1,d2: dicts whose keys and values are integers
:return: Returns a tuple of dictionaries according to the instructions above
'''
d3 = {};
d4 = {};
a = 5;
b = 10;
c = 15;
if f(a,b) == c:
for key in d1:
if key in d2:
d3.__setitem__(key, f(d1.get(key),d2.get(key)));
else:
d4.__setitem__(key,d1.get(key));
for key in d2:
if key not in d1:
d4.__setitem__(key,d2.get(key));
elif f(a,b) == False:
for key in d1:
if key in d2:
d3.__setitem__(key, f(d1.get(key), d2.get(key)));
else:
d4.__setitem__(key, d1.get(key));
for key in d2:
if key not in d1:
d4.__setitem__(key, d2.get(key));
rtrnTuple = (d3,d4);
return rtrnTuple;