0

I am trying to provide a simple input to a program using SublimeREPL on Sublime Text. Sample code below

print('Please print your name')
name = input()
print(name)

When I try to input my name via SublimeREPL as just

MyNameHere

I get the following error:

  File "input_test.py", line 2, in <module>
    name = input()
  File "<string>", line 1, in <module>
NameError: name 'MyNameHere' is not defined

however, if I input my name as a string such as

'MyNameHere'

I get no such error and the program prints my input. This program seems to work just fine in IDLE regardless of whether I define the input as a string or not. This seems to suggest to me that SublimeREPL cannot accept undefined data inputs? Is this an issue with SublimeREPL or is there something else I am missing?

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
stem__bar
  • 19
  • 4
  • 3
    It appears that SublimeREPL is using Python2. Please do not use Python2. – MisterMiyagi Oct 23 '20 at 15:21
  • What OS are you running? – MattDMo Oct 23 '20 at 17:33
  • 1
    In Python 2, `input()` evaluates the input as code and `raw_input()` gathers raw input as a string and returns it. The error you're seeing here definitely seems to be that; `'MyName'` is a string, but `MyName` is not valid code that it knows how to compile. If you meant to be using Python 2, use `raw_input()` instead. If you think you're using Python 3 as evidenced by your tag, you're not and your SublimeREPL is not configured properly and is running the wrong version. How you fix that may depend on your OS, as @MattDMo mentioned above. – OdatNurd Oct 23 '20 at 17:59
  • 1
    To mark a problem resolved, use the "Add an Answer" button to add an answer, and then click the checkmark to accept it (note that when you answer your own question, there's a delay before the accept checkmark becomes available). _Don't_ just edit "RESOLVED" into the title, or edit the answer into the question itself. – Charles Duffy Oct 24 '20 at 20:40
  • @CharlesDuffy thank you for the heads up - still quite new to stack overflow, so I appreciate the direction – stem__bar Oct 25 '20 at 17:51

1 Answers1

0

From a question edit:

This issue was caused due to misconfigured sublime text using python 2.x rather than python 3.x

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441