Skip to main contentSkip to solution

Identify the incorrect statement about exception handling in python.

Solution

✅ Correct Option: 2

The finally block executes always, whether or not an exception occurs, and even if the exception is not caught. It is used for clean-up tasks such as closing files or releasing resources. So saying it runs "only if the exception occurs" is incorrect.


Option 1: This is true, since except, else and finally clauses can only be written with a try block.

Option 3: This is true, as raise manually triggers an exception, for example raise ValueError("bad input")\texttt{raise ValueError("bad input")}.

Option 4: This is true, since one try can have several except blocks, each handling a different exception type.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question