Python Forum
Input error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Input error (/thread-10652.html)



Input error - vijays3 - May-30-2018

Hi

I am taking input from user and when I run this code I get the error. Please help what I am doing wrong here.

print('Please enter some text:')
x = input()
print('Text entered:', x)
print('Type:', type(x))
      


Error:
Please enter some text: vijay Traceback (most recent call last): File "C:/Program Files/Python/First.py", line 5, in <module> x = input() File "<string>", line 1, in <module> NameError: name 'vijay' is not defined >>>

I followed other post and issue is fixed. I am using python 2 and I should use raw_input in place of input function. Below code worked.


print('Please enter some text:')
x = raw_input()
print('Text entered:', x)
print('Type:', type(x))



RE: Input error - snippsat - May-30-2018

(May-30-2018, 08:18 AM)vijays3 Wrote: I followed other post and issue is fixed. I am using python 2 and I should use raw_input in place of input function. Below code worked.
Yes,and you should by using Python 3 not 2.
Install tutorials Windows, linux.