Python Forum

Full Version: Python Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
First of all, I am new here so I am sorry if I am posting in the wrong place, and I would appreciate a link to the write place so I can perform correctly in the future.

I am learning python and have bought a book but I am confused about the 'input' command. In the book it has the code:
name = input("Hi, what's your name? ")
, but when I run this and enter any response (in this case the name Sam) I get the error:
Traceback (most recent call last):
  File "/home/pi/Desktop/Newseession.py", line 1, in <module>
    name = input("Hi, what is your name? ")
  File "<string>", line 1, in <module>
NameError: name 'Sam' is not defined
Am I missing something? Thank you for any help.
this code is python3 and you are running it with python2
read https://python-forum.io/Thread-Python3-2...-raw-input

you should be using python3 as python2 support ended january 1st
(Feb-27-2020, 07:51 PM)Lighaldr Wrote: [ -> ]First of all, I am new here so I am sorry if I am posting in the wrong place, and I would appreciate a link to the write place so I can perform correctly in the future.

I am learning python and have bought a book but I am confused about the 'input' command. In the book it has the code:
name = input("Hi, what's your name? ")
, but when I run this and enter any response (in this case the name Sam) I get the error:
Traceback (most recent call last):
  File "https://mydataprovider.com/sites/", line 1, in <module>
    name = input("Hi, what is your name? ")
  File "<string>", line 1, in <module>
NameError: name 'Sam' is not defined
Am I missing something? Thank you for any help.

Thanks