Bird
0
0

What happens to the else block in a try-except-else structure if an exception is raised in the try block?

easy📝 Conceptual Q1 of 15
Python - Advanced Exception Handling
What happens to the else block in a try-except-else structure if an exception is raised in the try block?
AThe <code>else</code> block is skipped and not executed.
BThe <code>else</code> block runs before the <code>except</code> block.
CThe <code>else</code> block runs even if an exception occurs.
DThe <code>else</code> block runs only if an exception occurs.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the flow of try-except-else

    The try block runs first. If an exception occurs, control moves to the except block.
  2. Step 2: Role of else block

    The else block runs only if no exception occurs in the try block, so it is skipped if an exception happens.
  3. Final Answer:

    The else block is skipped and not executed. -> Option A
  4. Quick Check:

    else runs only if no exception = A [OK]
Quick Trick: Else runs only if try succeeds without exceptions [OK]
Common Mistakes:
  • Thinking else runs even if exception occurs
  • Confusing else with finally block
  • Assuming else runs before except

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes