+3 votes

1 Answer

+3 votes
by (user.guest)
Best answer


The answer is dependent on the version of Python you're running.

On Python 2

raw_input() takes the exact value of what was passed  to it, and returns it as a string.

input() is simply a raw_input() that is evaluated. i.e. eval(raw_input))

By implication, input() expects a syntactically correct python statement while raw_input() does not.

On Python 3

raw_input() from Python 2 was renamed to input() in Python 3.

What was previously defined as input() in Python 2 no longer exists in Python 3.

You can replicate the behaviour of the Python 2 input() by wrapping the new input() around the eval() function i.e. eval(input()).

Please leave a comment below if you found this answer helpful. Happy coding!

Related questions

Welcome to CPEN Talk
Solution-oriented students of computer engineering on one platform to get you that


Chuck Norris solved the Travelling Salesman problem in O(1) time. Here's the pseudo-code: Break salesman into N pieces. Kick each piece to a different city.