[Tutor] raw_input
Remco Gerlich
scarblac@pino.selwerd.nl
Wed, 20 Jun 2001 20:31:50 +0200
On 0, Brendhan Horne <brendhanhorne@yahoo.com> wrote:
> >>> 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 never told Python the the result of raw_input() should be called 'name'.
Try instead:
>>> name = raw_input("Enter your name:")
Enter your name:Remco
>>> print name
Brendhan
You didn't assign the result to some variable, so the interpreter simply
printed the result on the screen (the 'Brendhan' on the line after you typed
it in).
--
Remco Gerlich