🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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__)
  1. A.IndexError
  2. B.KeyError
  3. C.ValueError
  4. 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 →