Chapters
Python114 chapters

ReferenceDictionary methods

dict.keys()

A live view of the keys, in insertion order.

Signature

mapping.keys()

Returns

A view object. Wrap in list() for a list.

Example

Python
person = {"name": "Ada", "born": 1815}
print(list(person.keys()))
print("name" in person)

Output

['name', 'born']
True

See also