input_var = input ("Press 'E' and 'Enter' to Exit: ")
NameError: name 'e' is not defined
I am using Python 2.5. How I can overcome this error?
The Python "NameError: name is not defined" occurs when we try to access a variable or function that is not defined or before it is defined. To solve the error, make sure you haven't misspelled the variable's name and access it after it has been declared.
What Is a NameError in Python? In Python, the NameError occurs when you try to use a variable, function, or module that doesn't exist or wasn't used in a valid way. Some of the common mistakes that cause this error are: Using a variable or function name that is yet to be defined.
The Python "NameError: function is not defined" occurs when we try to call a function that is not declared or before it is declared. To solve the error, make sure you haven't misspelled the function's name and call it after it has been declared.
input
reads and evaluates a Python expression. When it tries to evaluate it, it looks for a variable e
, which is not defined, and fails.
You almost always want to use raw_input
instead. (And in Python3, input
has this behaviour.)
Or, better, on Unix, use readline so the user can edit their input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With