[Tutor] Newbie question re: user interaction

R. A. rob@jam.rr.com
Thu, 01 Feb 2001 17:49:59 -0600


I sent this earlier, but it didn't seem to make it to the list.

name=raw_input("What is your name? ")
print "Hello, " + name + "!"

Something like this should do the trick.

Rob

First Name Last Name wrote:
> 
> Hello,
>     I'm a clueless newbie who has been self-teaching Python (and programming) for approximately one week.  I have made my stab at immortality by writing a random-name generator and submitting it to the Useless Python Scripts page.
> 
> Anyway, I understand enough of Python to look up the bits I don't remember in the manual, write simple functions, &c.  The part in my manual (O'Reilly 'Learning Python') about classes is complete gibberish to me, but I'm sure that will change in time.
> 
> Anyway, what I'm writing to ask about is, how do I do the equivalent of the following BASIC function in Python?
> 
> 10 INPUT "What is your name?" N$
> 20 PRINT "Hello, " N$ "!"
> 
> This is a staggeringly simple piece of code and I instinctively feel that a well-designed language like Python must have a simple and elegant way of replicating it.  However, all I've managed to gather from the manual is that if I do something horribly complicated with the cmd module then I might be able to do something that vaguely mimics the code above.  Please tell me I'm wrong!
> 
> Thanks very much for any help, Gus Hungerford.
> 
> ------------------------------------------------------------
> --== Sent via Deja.com ==--
> http://www.deja.com/
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Visit the Useless Python Repository!
http://www.lowerstandard.com/python/pythonsource.html