Python Forum
input error help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: input error help (/thread-5785.html)



input error help - Cremno - Oct-21-2017



name = input("Enter Name: ")
print("Hello there "+name)

input("Press enter")
I'm encountering an error with this command. When I get the "Enter name" prompt and I enter
Me (Or anything else)
I get this error:
Error:
Traceback (most recent call last): File "G:\Python Saves\Tests\Hello.py", line 1, in <module> name = input("Enter Name: ") File "<string>", line 1, in <module> NameError: name 'Me' is not defined
However, if I enter
"Me" instead, it works. I know it should work without "" but for some reason, it doesn't.
Can anyone help me out with this?

I am running on windows 10.


RE: input error help - snippsat - Oct-21-2017

Use code tag BBcode help.

You are getting that error because you use Python 2.
Fix:
name = raw_input("Enter Name: ")
print("Hello there " + name)
But you should really use Python 3,follow Python 3.6 and pip installation under Windows.
Then it can look like this.
name = input("Enter Name: ")
print(f'Hello there {name}')



RE: input error help - Cremno - Oct-21-2017

I see. I downloaded python 3 but it would seem I was using an old installation. I guess that is a newbie for you haha, thank you so much.