🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Exceptions in Depth: all 10 questions

Quiz: Exceptions in Depth · Question 3 of 10

What does this print? (code)

What does this print?

def f():
    try:
        return "try"
    finally:
        print("finally", end=" ")
print(f())
  1. A.try
  2. B.try finally
  3. C.finally try
  4. D.finally
Answer & explanation

Correct answer: finally try

finally runs just before the function returns, so its print comes first.

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 →