Reserved words in Python

Article #011

In today's article, we will have a short discussion on reserved words in Python. Earlier we talked about the naming convention used for variables in Python. Apart from the naming convention, there are some reserved keywords which are not supposed to be used for naming a variable. On using these words as a variable name, they lose their functionality. For e.g. if we use 'print' as a variable name then we would no longer be able to use print() as a function. In order to use it as a function, we need to delete the variable before using it.

Similar to print, there are many reserved keywords in Python. Some of these are mentioned below.

  • and
  • del
  • from
  • not
  • while
  • as
  • elif
  • global
  • or
  • with
  • assert
  • else
  • if
  • pass
  • yield
  • break
  • except
  • import
  • print
  • class
  • exec
  • in
  • raise
  • continue
  • finally
  • is
  • return
  • def
  • for
  • lambda
  • try