ReferenceDictionary methods
dict.get()
The value for a key, or a default instead of raising.
Signature
mapping.get(key, default=None)Parameters
| Name | Means |
|---|---|
key | what to look up |
default | returned when the key is missing |
Returns
The value, or the default.
Example
Python
person = {"name": "Ada"}
print(person.get("name"))
print(person.get("age"))
print(person.get("age", "unknown"))Output
Ada None unknown