phanindhar1

Untitled

Jan 7th, 2023
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. def merge_dicts(dict1, dict2):
  2.     for key, value in dict2.items():
  3.         if key in dict1:
  4.             if isinstance(value, dict):
  5.                 merge_dicts(dict1[key], value)
  6.             elif isinstance(value, list):
  7.                 dict1[key].extend(value)
  8.             else:
  9.                 dict1[key] = value
  10.         else:
  11.             dict1[key] = value
Advertisement
Add Comment
Please, Sign In to add comment