Dict Methods
dict.update()
Merges entries into the existing dictionary. A source may supply keys and indexed lookup, or yield two-element iterables. Later occurrences overwrite earlier values; keyword entries are processed after the positional source. Overwriting leaves a key in its existing position; new keys appear in insertion order. Failed processing can leave earlier updates applied, so this is not an atomic transaction. Use a new mapping when mutation is undesirable.
Formal Syntax & Structure
python syntaxpython
mapping.update(**kwargs)mapping.update(mapping_or_pairs, /, **kwargs)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| mapping_or_pairs | Mapping or Iterable[Iterable] | Optional positional mapping-like object or stream of key-value pairs. |
| kwargs | keyword arguments | Additional string-key entries applied after the positional source. |
Return Value
None
Updates the original dictionary; returns no merged dictionary.
Working Example
Example Snippetpython
settings = {"theme": "light", "size": 2}result = settings.update([("theme", "dark"), ("zoom", 3)], size=4)print(settings)print(result)