Guest User

Untitled

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