Dictionary Entries
Exists?
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 handling
Return the value for key if the key is in the dictionary, else defaultValue.
If defaultValue is not given, it defaults to None.
- Using this method never raises a KeyError.
dict.get(key[, defaultValue])