Python3.4 Anaconda: Input() Function Broken?

766 Views Asked by At

I'm having trouble with the input() function in Python3.4 using the Anaconda integrated editor. If I just type

x = input()

into the editor, it returns a blank line that I can type text into. If I type:

foo

into this line, I would expect 'foo' be stored as a string with variable name x. But, instead I get:

NameError: name 'foo' is not defined

To make the function work as expected, I must instead type in:

'foo'

which is unfortunate because what I really want is just to pause my code and wait for an arbitrary user input, and I read somewhere that "wait = input()" is the most pythonic way to do this. Using that line in my actual script returns an "unexpected EOF" error - I assume as another symptom of the same problem. Can anyone suggest a workaround?

Note: I suspect this is an Anaconda-specific problem, given the following reference: https://docs.python.org/3.4/library/functions.html#input

Thanks for your time.

1

There are 1 best solutions below

0
On

Your code is being run by Python 2, not 3. I don't know enough about Anaconda to know if the problem is with their editor, or if you have your path messed up, but the problem is that the wrong version of Python is being used.