NameError
noun
say it: “NAYM AIR-er” /ˈneɪm ˈɛrər/
The error Python reports when code uses a name, such as a variable or function, that hasn't been defined, often because of a typo.
What is a NameError?
A NameError is the error Python stops with when a line uses a name it doesn't know: a typo, or a variable used before it was given a value. The message names the unknown name.
price = 4.50
prnt(price)
# NameError: name 'prnt' is not defined. Did you mean: 'print'?
In a sentence
- “The NameError pointed at prnt, and changing it to print made the receipt appear.”
- “Using total before the line that set it caused a NameError.”
Level: Novice · More Python terms at this level
Updated