SublimeREPL icon indicating copy to clipboard operation
SublimeREPL copied to clipboard

Text Input in Python does not work

Open omar19-meet opened this issue 8 years ago • 2 comments

I am using the SublimeREPL package in Sublime Text 3 to create a compatibility calculator between two individuals. My program relies on user input as the main source of material, but every time I try to run a simple code that asks for a text input, such as:

a=input("What is your name? ")
print(a)

When I type in my name, Omar, with no quotations, it will result in this NameError:

Traceback (most recent call last):
  File "test2.py", line 1, in <module>
    a=input("What is your name? ")
  File "<string>", line 1, in <module>
NameError: name 'Omar' is not defined

This code works however, if the text input is in quotations. However, for my purpose, it is incredibly inconvenient to have to insert quotation marks around the text that the user types every single time. I have seen videos where this worked with other people, and frankly, I'm stumped. If anyone knows what to do to make this work, or an alternative solution to this, please let me know. Any answers will be greatly appreciated.

omar19-meet avatar Nov 16 '17 18:11 omar19-meet

Hi, Sounds to me like you are running Python 2.7 and should use the raw_input function instead. In Python 3, the input function works as you are expecting, but in 2.7 it tries to interprete it as python code.

koalive avatar Dec 13 '17 15:12 koalive

Hi, I found the solution,the reason is sublimeREPL run current-file use python2. you need find sublimeREPL-config-python-Main.sublime-menu,turn the python to python3. then it's ok.

penny-w avatar Apr 27 '20 03:04 penny-w