Python Forum
Thread Rating:
  • 3 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
raw_input vs input
#1
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
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Going thru tutorials..."NameError: name 'raw_input' is not defined" hmonnier 4 4,169 Jul-14-2020, 02:19 PM
Last Post: BitPythoner
  raw_input rtbr17 3 3,655 Sep-26-2018, 09:36 PM
Last Post: nilamo
  URL via raw_input, passed to HTTP requests and output? johnnyaustin 1 4,872 Dec-08-2017, 11:22 PM
Last Post: johnnyaustin
  Help with raw_input Marshall_99 2 3,400 Mar-21-2017, 01:44 AM
Last Post: Marshall_99
  Cmd Module + raw_input tab [complete ruggierom 1 3,461 Feb-06-2017, 12:43 AM
Last Post: ruggierom
  Any way to get raw_input to work in my function? Pythonerous 4 5,183 Oct-27-2016, 05:03 PM
Last Post: Pythonerous

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020