0

I'm trying these lines in Python 3 using SublimeText:

a = input('Geben Sie bitte das Wort "Hallo" ein: ')
if a == "Hallo":
    print('Korrekt!')

Now if I run that in SublimeREPL I get

Geben Sie bitte das Wort "Hallo" ein: Hallo
Traceback (most recent call last):
  File "S79.py", line 1, in <module>
    a = input('Geben Sie bitte das Wort "Hallo" ein: ')
  File "<string>", line 1, in <module>
NameError: name 'Hallo' is not defined

***Repl Closed***

However, it works if I run it online.

I don't quite get it. In SublimeREPL it only works if I type

'Hallo'

instead of

Hallo

Any suggestions?

========== Update: So I did further dig into this problem, and I am starting to think that SublimeText uses Python 3 YET SublimeREPL runs my code in Python 2. For instance, raw_input produces an error in the same script if I build it but makes it work in SublimeREPL instead. Further evidence for that problem to exist I found here. Is that even possible and how can I change that?

KayAl
  • 3
  • 2
  • I'm not familiar with Sublime, but it looks like you're actually running it in Python 2, not Python 3. For details, see [this answer](https://stackoverflow.com/a/15129556/4518341). There should be a setting that lets you change that. – wjandrea Jan 24 '21 at 23:45
  • 1
    In SublimeREPL, what does `import sys; print(sys.version)` return? – MattDMo Jan 25 '21 at 01:43
  • @wjandrea I already considered that possibility, but my SublimeREPL-->tools-->build system is set to Python 3. – KayAl Jan 28 '21 at 21:54
  • @MattDMo 3.9.1 (v3.9.1:1e5d33e9b9, Dec 7 2020, 12:10:52) [Clang 6.0 (clang-600.0.57)] – KayAl Jan 28 '21 at 21:55

0 Answers0