raw_input

Bjorn Pettersen BPettersen at NAREX.com
Wed Jun 20 14:31:59 EDT 2001


> From: Brendhan Horne [mailto:brendhanhorne at bellsouth.net]
> 
> >>> raw_input ("Enter your name:")
> Enter your name:Brendhan
> 'Brendhan'
> >>> print name
> Traceback (innermost last):
>   File "<pyshell#7>", line 1, in ?
>     print name
> NameError: There is no variable named 'name'
> 
> Okay What did I do wrong it should have printed my name after 
> the print name
> command.

you need to assign the result of the call to raw_input to a variable
called name (otherwise Python has no way of knowing what you think it
should do... ;-)

>>> name = raw_input("Name: ")
Name: Bjorn
>>> print name
Bjorn

-- bjorn




More information about the Python-list mailing list