How to extend a dictionary in Python

Extending a dictionary adds all key-value pairs from one dictionary to another. For example, extending {“a”: 1, “b”: 2} with {“c”: 3, “d”: 4} results in {“a”: 1, “b”: 2, “c”: 3, “d”: 4}.

Solution for How to extend a dictionary in Python : You can use dict.update() to extend a dictionary Use dict.update(other) to extend a dictionary dict with the items from another dictionary other.


how-to-extend-a-dictionary-in-python