-1

I have been trying to run this python program using IDLE with Windows 7 and Python 2.7

myInput = input("Enter Something:")
print(myInput)

If i enter some integer value, it works fine. But when I enter some string I am getting following error.

Enter Something:qwer

Traceback (most recent call last): File "C:\Users\avmore\Desktop\hello.py", line 1, in myInput = input("Enter Something:") File "", line 1, in NameError: name 'qwer' is not defined

Can anyone please help?

1 Answers1

0

In python 2.7 use raw_input for strings. This was changed in Python 3.

Peter Ashwell
  • 4,292
  • 2
  • 18
  • 22
  • Thanks. It is working now. But as far as I know python is dynamically typed language. So if I am using raw_input for reading the string doesn't it contradict the basic philosophy? – Avinash More Mar 01 '15 at 10:25
  • See http://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input-and-input-in-python3-x. raw_input gets a string, input evaluates the value entered. Not related to types – Peter Ashwell Mar 01 '15 at 10:27