How to use 'python add to dictionary' in Python

Every line of 'python add to dictionary' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
615def addDict(base_dict,new_dict):
616 for k in new_dict.keys():
617 new_el=new_dict[k]
618 if not base_dict.has_key(k):
619 # nothing there?, just copy
620 base_dict[k]=new_el
621 else:
622 if type(new_el)==type({}): #another dictionary, recourse
623 addDict(base_dict[k],new_el)
624 else:
625 base_dict[k]+=new_el
68def update(self, dictionary=None):
69 if dictionary is not None:
70 for k, v in dictionary.items():
71 self.data[k] = v

Related snippets