dictionary.get( ) vs dictionary[ ]
Last updated
Was this helpful?
Last updated
Was this helpful?
dictionary.get
allows you to provide a default value if the key is missing:
returnsdefault_value
(whatever you choose it to be), whereas
would raise aKeyError
.
If omitted,default_value
isNone
, such that
returnsNone
just like
would.
Reference: