Noob raw_input question

John Posner jjposner at optimum.net
Wed Feb 24 19:29:06 CET 2010


On 2/24/2010 12:39 PM, Abigail wrote:
> Yesterday I downloaded and installed Python 3.1 and working through some
> examples but I have hit a problem
>
>>>> a = raw_input("Enter a number" )
> Traceback (most recent call last):
>    File "<pyshell#6>", line 1, in<module>
>      a = raw_input("Enter a number" )
> NameError: name 'raw_input' is not defined>>>a = raw_input("Enter a number
> ")
>
> What am I doing wrong?
>
>

The Python 2 built-in function "raw_input" has been renamed to "input" 
in Python 3. You'll probably run into this, too:

  Python 2: print "hello, world"
  Python 3: print("hello, world")

You might want to install Python 2 if you're working your way through a 
tutorial that's targeted at that "generation" of the language.

-John





More information about the Python-list mailing list