ReviseAlgo Logo

Basic Syntax

Python Keywords

Reserved words in Python

Interview: Language fundamentals

Last Updated: June 12, 2026 5 min read

Python has 35 reserved keywords that cannot be used as variable, function, or class names. They form the structural backbone of Python syntax. Understanding each keyword's purpose is fundamental to writing correct Python code.

Control Flow Keywords

  • if, elif, else — conditional branching
  • for, while — loops
  • break, continue, pass — loop control
  • match, case — structural pattern matching (Python 3.10+)

Definition Keywords

  • def — define a function
  • class — define a class
  • return, yield — return values from functions/generators
  • lambda — anonymous function
  • async, await — asynchronous programming

Import & Module Keywords

  • import, from, as — module imports
  • global, nonlocal — variable scope control

Error Handling & Context

  • try, except, else, finally, raise — exception handling
  • with — context managers (resource management)
  • assert — debugging assertions
  • del — delete references

Special Values

  • True, False — boolean values
  • None — null/absence of value
  • and, or, not, in, is — logical and identity operators

Soft Keywords (Python 3.10+)

match and case are "soft keywords" — they only have special meaning inside a match statement. You can still use them as variable names elsewhere (though it's not recommended).

Use Cases

Understanding Python language structure for debugging

Avoiding naming conflicts with reserved keywords

Writing correct control flow and error handling

Using scope control keywords (global, nonlocal) properly

Common Mistakes

Accidentally using a keyword as a variable name (SyntaxError)

Confusing global vs nonlocal for nested function scope

Not understanding pass vs continue vs break in loops

Using lambda when a proper def would be more readable