Bird
Raised Fist0

Which of the following is the correct syntax for a try-except-finally block in Python?

easy📝 Syntax Q12 of Q15
Python - Advanced Exception Handling
Which of the following is the correct syntax for a try-except-finally block in Python?
Aexcept: pass try: pass finally: pass
Btry: pass finally: pass except: pass
Ctry: pass except: pass finally: pass
Dtry: pass except: pass else: pass
Step-by-Step Solution
Solution:
  1. Step 1: Recall the order of blocks

    The correct order is try, then except, then finally.
  2. Step 2: Check each option's order

    try: pass except: pass finally: pass follows the correct order. try: pass finally: pass except: pass places finally before except, which is invalid. except: pass try: pass finally: pass starts with except, which is wrong. try: pass except: pass else: pass uses else but no finally.
  3. Final Answer:

    try, except, finally in correct order -> Option C
  4. Quick Check:

    try-except-finally order = C [OK]
Quick Trick: Remember order: try, except, then finally. [OK]
Common Mistakes:
MISTAKES
  • Placing finally before except
  • Starting with except block
  • Confusing else with finally

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes