Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string name is not defined
#1
print("Enter your name:")
x = input()
print("Hello, " + x)
after compiling the program i get this following error

Enter your name:
listingpython
Traceback (most recent call last):
  File "input.py", line 2, in <module>
    x = input()
  File "<string>", line 1, in <module>
NameError: name 'listingpython' is not defined
Reply
#2
what version of python? if on python 2 - this code is for python3
read https://python-forum.io/Thread-Python3-2...-raw-input
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
i am using Python 2.7 thank you for help
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python library not defined in user defined function johnEmScott 2 3,773 May-30-2020, 04:14 AM
Last Post: DT2000
  get string how it is defined bhojendra 10 5,380 Apr-29-2019, 08:00 AM
Last Post: buran

Forum Jump:

User Panel Messages

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