NameError from Python input () function

input_var = input ("Press 'E' and 'Enter' to Exit: ") NameError: name 'e' is not defined 

I am using Python 2.5. How can I overcome this mistake?

+6
source share
1 answer

input reads and evaluates a Python expression. When he tries to evaluate it, he searches for the variable e , which is not defined and is not executed.

You almost always want to use raw_input . (And in Python3, input has this behavior .)

Or, better, on Unix, use readline so the user can edit their input.

+27
source

Source: https://habr.com/ru/post/944609/


All Articles