I am learning python and have this error . I can figure out where\what the error is in the code.
File "<string>", line 1, in <module>
Name = ""
Desc = ""
Gender = ""
Race = ""
# Prompt user for user-defined information
Name = input('What is your Name? ')
Desc = input('Describe yourself: ')
Traceback (most recent call last):
File "/python/chargen.py", line 19, in <module>
Name = input('What is your Name? ')
File "<string>", line 1, in <module>
NameError: name 'd' is not defined
In Python 2.x, input()
expects something which is a Python expression, which means that if you type d
it interprets that as a variable named d. If you typed "d"
, then it would be fine.
What you probably actually want for 2.x is raw_input()
, which returns the entered value as a raw string instead of evaluating it.
Since you're getting this behavior, it looks like you're using a 2.x version of the Python interpreter - instead, I'd go to www.python.org and download a Python 3.x interpreter so that it will match up with the book you're using.