Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Given dictionaries, d1 and d2, create a new dictionary with the following
- # property: for each entry (a, b) in d1, if there is an entry (b, c) in d2, then
- # the entry (a, c) should be added to the new dictionary. For example, if d1 is
- # {2:3, 8:19, 6:4, 5:12} and d2 is {2:5, 4:3, 3:9}, then the new dictionary
- # should be {2:9, 6:3} Associate the new dictionary with the variable d3
- d3 = {}
- for (k, v) in d1.iteritems():
- if v in d2:
- d3[k] = d2[v]
Add Comment
Please, Sign In to add comment