The 'raise' keyword in Python is used ____.
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.
Related questions:
2025: 30 May Shift 2
2026: 31 May Shift 1
2026: 29 May Shift 1