dictionary.get( ) vs dictionary[ ]
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: https://stackoverflow.com/questions/11041405/why-dict-getkey-instead-of-dictkey
Last updated