fredrik at pythonware.com
Mon Nov 7 18:28:47 CET 2005
"john boy" <xray_alpha_charlie at yahoo.com> :
>I am having trouble with the following example used in a tutorial:
> print "Halt !"
> s = raw_input ("Who Goes there? ")
> print "You may pass,", s
> I run this and get the following:
> Who Goes there?
> --thats it....if I hit enter again "You may pass,"
> In the example after running you should get:
> Who Goes there? Josh
> You may pass, Josh
> I'm assuming s=Josh...but that is not included in the statement at all
> I don't know how you put "Josh" in or how you got it to finish running
> w/o hitting enter after "Who goes there?"
> What am I doing wrong?
I think you're supposed to type "Josh" (or any other name, without the quotes)
*before* you hit enter.
(raw_input() reads a string of characters from the terminal, and returns them
as a string. if you don't type anything, there's nothing to return, and nothing to
More information about the Python-list