[Tutor] printing an acronym (fwd)
Allen John Schmidt, Jr.
ajschmidt at fredericksburg.com
Mon Sep 26 20:10:54 CEST 2005
Or a shorter version,
a=lambda n: "".join([x[0].upper() for x in n.split()])
Then it is just:
>>> a('random access memory')
'RAM'
Danny Yoo wrote:
>Forwarding to tutor
>
>---------- Forwarded message ----------
>Date: Mon, 26 Sep 2005 08:32:02 -0500
>From: Jason Massey <jason.massey at gmail.com>
>To: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
>Subject: Re: [Tutor] printing an acronym
>
>Something like this:
>
>def acro(a):
>... b = a.split()
>... c = ""
>... for d in b:
>... c+=d[0].upper()
>... return c
>
>other than the horrible variable naming, it works.
>
>
>
>>>>acro('international business machines')
>>>>
>>>>
>'IBM'
>
>On 9/25/05, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050926/abe7dfda/attachment.htm
More information about the Tutor
mailing list