I am trying to execute following code:
x = input('hello')
print (x)
But this code works on the command line:
I am trying to execute following code:
x = input('hello')
print (x)
But this code works on the command line:
Since you're using Python 2.7, it's better to use raw_input()
instead of input()
, as the latter tries to determine the type of the input and convert it automatically. raw_input()
will always return a string.
x = raw_input('hello ')
print (x)
As @Darius pointed out, if you leave it the way you wrote it, and type "dfd"
in the console instead of dfd
, it will work. But raw_input()
is the safe and proper method in Python 2.x.