[Tutor] Simple Python Problem

Keith Lucas kwl at aber.ac.uk
Mon Sep 6 16:16:28 CEST 2010


What is wrong with the following, apparently almost straight out of Python Programming
by Michael Dawson?



# Declare variable and initialise (overkill!).
name = "ABCDEFG"

# Get value.
name = input("What is your name? ")

# Echo value
print(name)

# Issue greeting
print("Hi ", name)


Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32 Type
"copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
What is your name? Keith

Traceback (most recent call last):
  File "C:\Documents and Settings\User\My Documents\My Files\Staff\Keith
Lucas\Education\Python\Learn_Input_01.py", line 5, in <module>
    name = input("What is your name? ")
  File "<string>", line 1, in <module>
NameError: name 'Keith' is not defined






More information about the Tutor mailing list