1

I am trying to execute following code:

x = input('hello')
print (x)

enter image description here

But this code works on the command line:

enter image description here

Will
  • 24,082
  • 14
  • 97
  • 108

1 Answers1

2

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.

Will
  • 24,082
  • 14
  • 97
  • 108