Newbie Question - String Input

Alex Martelli aleaxit at yahoo.com
Sun Sep 3 02:24:04 EDT 2000


"Sonic Hedgehog" <celtic at ix.net.au> wrote in message
news:39b1dd6e.2207206 at news.ix.net.au...
> I am using Python on a Wintel machine and I am trying to get Python to
> accept string data.  In the following program (a very basic program)
> Python accepts numerical data without any problems but will not accept
> any string data at all - the program crashes with the following error:
>
> Traceback (innermost last):
> File "hello.py", line9, in ?
> userName=input("What is your name? ")
> File "<string>", in line 0, in ?
> NameError: whatever_I_Entered
>
> Would someone please tell me what it is that I am doing wrong.  I am
> sure it is a rather simple to rectify.

The "input" built-in function requires the user to enter a valid
Python expression; to enter a string, the user needs to use
quotes around it.  To accept string input, your program can
use the "raw_input" built-in function instead of "input".


> And if someone knows of any websites that have good tutorials for
> Python please email me with the addresses.

www.python.org has a few good links to tutorials as a part of
its documentation section.


Alex






More information about the Python-list mailing list