Variable Names and KeywordsΒΆ

If you give a variable an illegal name, you get a syntax error:




(wrongassignment)

Keywords define the language’s syntax rules and structure, and they cannot be used as variable names.

Python has thirty-something keywords:

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

Programmers generally choose names for their variables that are meaningful to the human readers of the program to remember what the variable is used for.

Next Section - Statements and Expressions