Python raises a KeyError whenever a dict() object is requested a value using format a = adict[key] if key is not in the dictionary.
If you don't want to have an exception but default value used instead, you can use get() method:
Even more handy is somewhat controversially-named setdefault(key, val) which sets the value of key only if it is not already in the dict, and returns the value in any case: