I’m completely lost as to why this isn’t working. Should work precisely, right?
UserName = input("Please enter your name: ")
print ("Hello Mr. " + UserName)
raw_input("<Press Enter to quit.>")
I get this exception:
Traceback (most recent call last):
File "Test1.py", line 1, in <module>
UserName = input("Please enter your name: ")
File "<string>", line 1, in <module>
NameError: name 'k' is not defined
It says NameError 'k', because I wrote 'k' as the input during my tests. I’ve read that the print statement used to be without parenthesis but that has been deprecated right?
Do not use
input()in 2.x. Useraw_input()instead. Always.