Chapters
Python114 chapters

ReferenceDictionary methods

dict.items()

A view of key and value pairs, which is what you usually want in a loop.

Signature

mapping.items()

Returns

A view of (key, value) tuples.

Example

Python
person = {"name": "Ada", "born": 1815}
for key, value in person.items():
    print(key, "=", value)

Output

name = Ada
born = 1815

See also