Raw_input vs input


#1

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

I’m use to the input () but I’ve noticed that the “control flow” exercise asked for raw_input().
https://www.codecademy.com/courses/learn-python/lessons/conditionals--control-flow/exercises/go-with-the-flow?action=resume_content_item

answer=raw_input("The left…)

What is the difference between input() and raw_input()?


#2

For python2 i assume? given raw_input does no longer exist in python3.

raw_input() is the function you want to use in python2, input() will evaluate the input as code.


#3

So, going forward, in Python 3, I will use input() rather than raw_input()?

Thanks,
Chantal


#4

yes, but understanding why and how might be quite valuable:

https://stackoverflow.com/questions/3800846/differences-between-input-and-raw-input