In a tutorial, I read that that there is a difference between input and raw_input. I discovered that they changed the behavior of these functions in the Python 3.0. What is the new behavior?
And why in the python console interpreter this
x = input()
Sends an error but if I put it in a file.py and run it, it does not?
In python 2.x,
raw_input()returns a string andinput()evaluates the input in the execution context in which it is calledIn python 3.x,
inputhas been scrapped and the function previously known asraw_inputis nowinput. So you have to manually callcompileand thanevalif you want the old functionality.In 3.x, the above session goes like this
So you were probably getting an error at the interpretor because you weren’t putting quotes around your input. This is necessary because it’s evaluated. Where you getting a name error?