0
name = input('what is your name? ')
print('hi ' + name)

The output shows:

what is your name? John
Traceback (most recent call last):
  File "/Users/xx/PycharmProjects/Tutorial/basic_tutorial.py", line 1, in <module>
    name = input('what is your name? ')
  File "<string>", line 1, in <module>
NameError: name 'John' is not defined

It is not working when inputting John without quotes. However, I believe the syntax is not wrong in Pycharm. Anyone knows why?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
ZKK
  • 627
  • 1
  • 10
  • 16
  • This does not have anything to do with Pycharm. You are simply using Python 2 and there `input` is equivalent to `eval(input(...))` in Python 3. You should either use `raw_input`, or **ALOT** more preferably, move to Python 3! – Tomerikoo Apr 04 '20 at 19:24

1 Answers1

0

Make sure if you are using Python 3 as an interpreter. Python 2 has some other syntax for input as far as I remember.

Syed Faizan Ali
  • 361
  • 1
  • 8