I use the latest version of Python 3.6.1
I use the input()
function in my script
F:\MyPython> type new.py
input_variable = input("Enter your name: ")
print ("your name is" + input_variable)
and I get the following error:
Traceback (most recent call last):
File "F:\MyPython\new.py", line 1, in <module>
input_variable = input("Enter your name: ")
File "<string>", line 1, in <module>
NameError: name 'xyz' is not defined
But when I use raw_input()
I get the correct output.
Why do I get an error for input()
even after installing the latest version?
It is not an error x = input("")
takes only integers as input.
x = raw_input("")
is for string you might be trying to input 'string' using input() method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.