Chapters
Python114 chapters

ReferenceException types

NameError

A name that has not been assigned, usually a typo.

Signature

NameError(message)

Returns

Raised when the name is looked up.

Example

Python
try:
    print(mispelled_name)
except NameError as problem:
    print("NameError:", problem)

Output

NameError: name 'mispelled_name' is not defined

See also