Guest User

Untitled

a guest
Jan 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. a = {'x': [1,2,3], 'y': 1, 'z': set([1,2,3]), 'w': 'qweqwe', 't': {'a': [1, 2]}, 'm': [1]}
  2. b = {'x': [4,5,6], 'y': 4, 'z': set([4,2,3]), 'w': 'asdf', 't': {'a': [3, 2]}, 'm': "wer"}
  3.  
  4. {'x': [1,2,3,4,5,6], 'y': 5, 'z': set([1,2,3,4]), 'w': 'qweqweasdf', 't': {'a': [1, 2, 3, 2]}, 'm': ([1], "wer")}
  5.  
  6. for key in a.keys():
  7. if type(a[key]) is type(b[key]):
  8. if type(a[key]) is list or type(a[key]) is int or type(a[key]) is str:
  9. lis = a[key] + b[key]
  10. dicty[key] = lis
  11. elif type(a[key]) is set:
  12. lis = list(a[key]) + list(b[key])
  13. dicty[key] = set(lis)
  14. elif type(a[key]) is dict:
  15. # print func1(a[key],b[key])
  16. dicty(a.items() + b.items())
  17. else:
  18. dicty[key] = tuple(a[key]) + tuple(b[key])
  19. return dicty
Add Comment
Please, Sign In to add comment