PYTHON RESERVED WORDS
Every programming language has a set of reserved words, which is a set of words that cannot be used as identifiers, and Python is no exception. The Python reserved words are: and, exec, not, assert, finally, or, break, for, pass, class, from, print, continue, global, raise, def, if, return, del, import, try, elif, in, while, else, is, with, except, lambda, and yield.
If you inadvertently use a reserved word as a variable, you will see an “invalid syntax” error message instead of a “reserved word” error message. For example, suppose you create a Python script test1.py with the following code:
break = 2
print('break =', break)
If you run the preceding Python code you will see the following output:
File "test1.py", line 2
break = 2
^
SyntaxError: invalid syntax
However, a quick inspection of the Python code reveals the fact that you are attempting to use the reserved word break as a variable.