input string in python 3 -
i have string variable test, in python 2.7 works fine.
test = raw_input("enter test") print test
but in python 3.3. use
test = input("enter test") print test
with input string sdas
, , error message
traceback (most recent call last): file "/home/ananiev/pycharmprojects/piglatin/main.py", line 5, in test = input("enter test") file "", line 1, in nameerror: name 'sdas' not defined
you're running python 3 code python 2 interpreter. if weren't, print
statement throw syntaxerror
before ever prompted input.
the result you're using python 2's input
, tries eval
input (presumably sdas
), finds it's invalid python, , dies.
Comments
Post a Comment