Sobes.tech
Intern
236

What reserved words exist in Python?

Answer from AI

sobes.tech AI

# List of reserved words in Python.
# They cannot be used as variable, function, or class names.
# Imported from builtins
keywords = [
    'False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await',
    'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except',
    'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is',
    'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try',
    'while', 'with', 'yield'
]

There are 35 reserved words in total.

  • Values: False, None, True.
  • Operators: and, or, not, is, in.
  • Flow control: if, elif, else, for, while, break, continue, pass, return, yield.
  • Declarations: def, class, import, from, as.
  • Exception handling: try, except, finally, raise, assert.
  • Scope management: global, nonlocal.
  • Resource management: with.
  • Object deletion: del.
  • Asynchronous (Python 3.5+): async, await.

Reserved words are case-sensitive.