Python 3 has 35 keywords or reserved words; they cannot be used as identifiers.

  • and
  • as
  • assert
  • async
  • await
  • break
  • class
  • continue
  • def
  • del
  • elif
  • else
  • except
  • False
  • finally
  • for
  • from
  • global
  • if
  • import
  • in
  • is
  • lambda
  • None
  • nonlocal
  • not
  • or
  • pass
  • raise
  • return
  • True
  • try
  • while
  • with
  • yield

In addition, Python 3 also has 4 soft keywords, including type added in Python 3.12. Unlike regular hard keywords, soft keywords are reserved words only in the limited contexts where interpreting them as keywords would make syntactic sense. These words can be used as identifiers elsewhere, in other words, match and case are valid names for functions and variables.

  • _
  • case
  • match
  • type

Notes

  • async and await were introduced in Python 3.5.
  • True and False became keywords in Python 3.0. Previously they were global variables.
  • nonlocal was introduced in Python 3.0.

match, case and _ were introduced as keywords in Python 3.10.