I have a dict with main data (roughly) as such: {\'UID\': \'A12B4\', \'name\': \'John\', \'email\': \'hi@example.com}
and I have another dict like:
you want to use the dict.update
method:
d1 = {'UID': 'A12B4', 'name': 'John', 'email': 'hi@example.com'}
d2 = {'UID': 'A12B4', 'other_thing': 'cats'}
d1.update(d2)
Outputs:
{'email': 'hi@example.com', 'other_thing': 'cats', 'UID': 'A12B4', 'name': 'John'}
From the Docs:
Update the dictionary with the key/value pairs from other, overwriting existing keys. Return None.
If you want to join dictionaries, there's a great built-in function you can call, called update
.
Specifically:
test = {'A': 1}
test.update({'B': 2})
test
>>> {'A':1, 'B':2}