[Tutor] Newbie question re: user interaction

Kalle Svensson kalle@gnupung.net
Fri, 2 Feb 2001 02:28:51 +0100


--+HP7ph2BbKc20aGI
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Sez First Name Last Name:
> Anyway, what I'm writing to ask about is, how do I do the equivalent of
> the following BASIC function in Python?
>=20
> 10 INPUT "What is your name?" N$
> 20 PRINT "Hello, " N$ "!"

n =3D raw_input("What is your name?")
print "Hello,", n

Note that there's no space in the "Hello," string.  The print statement adds
one space between each comma separated argument:
>>> print "a", "b", "c"
a b c
>>>

Also, a good idea is to check out the built in functions, there are quite a
few nice tools there:
http://www.python.org/doc/current/lib/built-in-funcs.html
And indeed, the library reference is your friend:
http://www.python.org/doc/current/lib/

> Please tell me I'm wrong!

You're wrong! <wink>

HTH,
  Kalle

P.S.  I might add that local time is 02:28 (AM).  I really should go to bed.
--=20
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD

--+HP7ph2BbKc20aGI
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6eg1TdNeA1787sd0RAu98AJ9u+vayBvFAgQqt+RAYXW60tm26QQCgu+wN
sw8UyttOcEBNDV0UX8hiay4=
=Fj7O
-----END PGP SIGNATURE-----

--+HP7ph2BbKc20aGI--