Chapters
Python114 chapters

ReferenceDictionary methods

dict.update()

Copies the pairs from another mapping in, overwriting on a clash.

Signature

mapping.update(other)

Parameters

NameMeans
othera dict, an iterable of pairs, or keyword arguments

Returns

None.

Example

Python
settings = {"colour": "black", "size": 10}
settings.update({"size": 12})
print(settings)
print({"a": 1} | {"a": 2, "b": 3})

Output

{'colour': 'black', 'size': 12}
{'a': 2, 'b': 3}

See also