Which keyword starts a block for handling exceptions in Python?

The story behind the answer

The keyword that starts a block for handling exceptions in Python is `try`.

Python places code that might fail inside a `try` block. If an exception occurs, one or more `except` clauses can respond to specific error types, such as `ValueError` or `FileNotFoundError`. An optional `else` clause runs when no exception occurs, while `finally` runs whether an exception happened or not.

A common mix-up is choosing `except`, because it contains the handler, but `except` does not begin the protected block. Python also does not use `catch` for ordinary exception handling; that keyword belongs to languages such as Java, JavaScript, and C++. The general pattern is `try:`, followed by indented statements, then `except:` or a more specific exception handler.

Python adopted this structured approach to make error handling explicit without requiring every function to return a separate error code. Exceptions can also be raised deliberately with `raise`, allowing a program to signal invalid input or an unrecoverable condition.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: