There is one question I am working on and got a very close answer... basically, the question is that you get two dictionaries and you have to find elements that intersect from both dictionaries and then create those elements (one same key from both dicts and two values from both dics) in a new dictionary.
a = { A :17, B :31, C :42, D :7, E :46, F :39, G :9}
b = { D :8, E :3, F :2, g :5}
def intersect(a,b):
c = set(a).intersection(set(b))
d = {}
for i in c:
if i in a:
d[i] = int(a[i]),int(b[i])
return d
OUTPUT: { E : (46, 3), D : (7, 8), F : (39, 2)}
我想获得这样的产出,如{E:46、3、D:7、8、F:39、2}
How do I get rid of the parentheses around the values?