Python Forum
raw_input vs input - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: raw_input vs input (/thread-14208.html)



raw_input vs input - EmilySenechal - Nov-20-2018

I'm having a hard time understanding the difference between raw_input and input. Can someone dumb it down for me?
Thank you,
Emily Senechal


RE: raw_input vs input - ichabod801 - Nov-20-2018

Basically, raw_input = eval(input). The detail is that raw_input returns a string. However input tries to evaluate that string as a Python expression before returning the result.

That's how it works in Python 2.7 and earlier. In Python 3.0 and later, raw_input does not exist, and input works like raw_input in 2.7 (it just returns a string without trying to evaluate it.

If at all possible you should use Python 3.0 or later (current 3.7 I believe). End of life for Python 2.7 is in a little over a year.