← Quiz: Exceptions and Files: all 15 questions
Quiz: Exceptions and Files · Question 8 of 15
What does this print? (code)
What does this print?
try:
[].pop()
except IndexError as e:
print(type(e).__name__)
- A.IndexError
- B.KeyError
- C.ValueError
- D.An error
Answer & explanation
Correct answer: IndexError
Popping from an empty list raises IndexError.
Can you get the rest right without peeking?
Take the timed Quiz: Exceptions and Files quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →