9
def main()

     name = input ("Please enter your name")

     print ("your name is", name)

In this program,(written in python IDLE) when I run it, and enter my name I get this error message.

Traceback (most recent call last):

 File "C:\Users\********\Documents\PYTHON\hello world.py", line 66, in ?

   main()

  File "C:\Users\********\Documents\PYTHON\hello world.py", line 5, in main

    name = input ("Please enter your name")

  File "<string>", line 0, in ?

NameError: name 'Jim' is not defined

What does not defined mean? Jim was the input, how can I define the input while it could be any conbination of letters?

Elderry
  • 1,902
  • 5
  • 31
  • 45
jim
  • 91
  • 1
  • 3
  • Try to write a script and execute it, it will be easier to understand. – sorin May 28 '11 at 18:28
  • For starters, you don't need parens around your print statement, but that was probably just a typo... – Jeff May 28 '11 at 18:29

1 Answers1

16

input() in 2.x interprets its input as Python code. Use raw_input() instead. And stop applying 3.x documentation to 2.x.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358