values()
to find an entry
Use .values()
to find the presence of an entry
in a dictionary.
d = {'1': 'one', '3': 'three', '2': 'two', '5': 'five', '4': 'four'} 'one' in d.values() # True
.get()
for graceful error handlingReturn the value
for key
if the key
is in the dictionary
, else defaultValue
.
If defaultValue
is not given, it defaults to None
.
KeyError
.dict.get(key[, defaultValue])