Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Input error
#1
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))
Reply
#2
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error in Using INPUT statement gunwaba 1 2,017 Jul-03-2022, 10:22 PM
Last Post: deanhystad
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 1,932 Oct-06-2021, 09:39 AM
Last Post: menator01
  Pyspark SQL Error - mismatched input 'FROM' expecting <EOF> Ariean 3 47,836 Nov-20-2020, 03:49 PM
Last Post: Ariean
  EOF error while taking input ShishirModi 1 2,534 Sep-27-2020, 11:28 AM
Last Post: jefsummers
  Input Error Dream 2 2,398 Jul-12-2020, 05:41 PM
Last Post: bowlofred
  Getting an error while using input function dcsethia 5 2,856 May-11-2020, 04:59 PM
Last Post: buran
  catch input type error mcmxl22 5 2,969 Aug-11-2019, 07:33 AM
Last Post: wavic
  inserting input gives me error message RubberNuggets 3 2,504 Jan-15-2019, 06:17 PM
Last Post: buran
  an input error or elif error , how can i fix this the_fire_pharaoh 1 2,326 Dec-15-2018, 09:47 PM
Last Post: Gribouillis
  Getting Error : User Input aankrose 1 2,977 Sep-06-2018, 04:55 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020