Skip to main contentSkip to solution

The 'raise' keyword in Python is used ____.

Solution

✅ Correct Option: 1

The raise keyword triggers an exception on purpose. It stops normal execution and passes the error up to the nearest matching except block, as in raise ValueError("invalid input").


Option 2: avoiding an exception is not what raise does. Avoiding errors is done with checks or by catching them with try/except.

Option 4: raise does not find or detect exceptions. Python detects them automatically when an error occurs.

Quick memory: raise creates an exception, try/except handles it.

Keyboard Shortcuts

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