Python Forum
What might be the cause of this?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What might be the cause of this?
#1
Here is my python code
Name = input("Tell me your name: ")
print("Hello ", Name)
But when i run the program i get this error

C:\Python27>python hello.py
Tell me your name: VIN
Traceback (most recent call last):
  File "hello.py", line 1, in <module>
    Name = input("Tell me your name: ")
  File "<string>", line 1, in <module>
NameError: name 'VIN' is not defined
Reply
#2
In python2, input() will try to run whatever you type as if it's python code. You should use raw_input() instead.

In python3, input was removed, and raw_input was renamed to be input, since what you're seeing is almost never what you want.
Also, python2 is nearing it's end of life, and you should probably use a newer version (python3 has been out for almost 10 years at this point). https://pythonclock.org/
Reply
#3
Thank you nilamo it worked now. And about python version 3 i will surely follow too.
Reply


Forum Jump:

User Panel Messages

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