[Tutor] Newbie question re: user interaction

wilson edgar pinto babyboy@oninet.pt
Thu, 1 Feb 2001 23:54:59 -0000


yes Gus, is much  more simple than that
just try  this

name = raw_input("hello what's your name? ")
print "nice to meet you", name

 in other words, raw_input, print whatever you write between parenthesis as
a prompt and and then ssaves the value and because, if you assign it to a
variable in this case "name", you can reuse it after

and you can use INPUT that lets you deal with numbers, c'os raw_input is for
strings

hope that helped
----- Original Message -----
From: "First Name Last Name" <dis_gus_ted@my-deja.com>
To: <tutor@python.org>
Sent: Thursday, February 01, 2001 8:05 AM
Subject: [Tutor] Newbie question re: user interaction


> 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