Built-in Exceptions
LookupError — exception class
Base for failed lookup operations, notably IndexError and KeyError. Codec name lookup can also raise this base class. Catch it only when those different failures can be handled in the same way. Catch LookupError when this category is the recovery boundary; do not rely on the exact human-readable message.
Formal Syntax & Structure
python syntaxpython
LookupErrorReturn Value
type
The class object LookupError; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
data={}try: data["missing"]except LookupError as error: print(type(error).__name__)