← Quiz: Exceptions in Depth: all 10 questions
Quiz: Exceptions in Depth · Question 8 of 10
What does this print? (code)
What does this print?
class AppError(Exception):
pass
class LoginError(AppError):
pass
try:
raise LoginError("wrong password")
except AppError as e:
print(type(e).__name__, e)
- A.AppError wrong password
- B.LoginError wrong password
- C.wrong password
- D.An error
Answer & explanation
Correct answer: LoginError wrong password
except AppError catches its subclass, and e is still the LoginError object.
Can you get the rest right without peeking?
Take the timed Quiz: Exceptions in Depth quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →