In python 2.x, raw_input() returns a string, and input() evaluates the input in the execution context in which it is called
>>> x = input() "hello" >>> y = input() x + " world" >>> y 'hello world'
In python 3.x, input been canceled, and a function formerly known as raw_input is now input . Therefore, you need to manually call compile and eval if you want to use the old functions.
python2.x python3.x raw_input() --------------> input() input() -------------------> eval(input())
In 3.x, the above session is as follows
>>> x = eval(input()) 'hello' >>> y = eval(input()) x + ' world' >>> y 'hello world' >>>
So, you probably made a mistake in the interpreter because you did not put quotation marks around your input. This is necessary because it is being evaluated. Where do you get the name error?
aaronasterling
source share