LookupError
The built-in parent class of IndexError and KeyError: the errors raised when a key or index is not found.
In more detail
An except LookupError clause catches both a bad list index and a missing dictionary key. Because the first matching except clause wins, a LookupError clause placed above a KeyError clause leaves the KeyError clause unreachable.
Related terms
- IndexError — The exception raised when you use an index beyond the end of a string, list or tuple.
- KeyError — The Python exception raised when you look up a dictionary key that does not exist.
- exception hierarchy — The family tree of exception classes, with BaseException at the top and Exception above nearly every error you will catch.
Taught in
- The Exception Family Tree — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Try, Except, Else And Finally — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Functions And Exceptions Sprint — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Twelve Traps, One Shape Each — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Mock, Review And Exam Day — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Handlers, args, raise And assert — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Exception Classes Of Your Own — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Exceptions Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Twelve Traps, Mostly Objects — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Mock, Review And Exam Day — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep