[Tutor] printing an acronym (fwd)

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Sep 26 19:58:52 CEST 2005


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:
>
>
> On Sat, 24 Sep 2005 andrade1 at umbc.edu wrote:
>
> > How could I get the following to print out an acronym for each phrase
> > entered such as if I entered random access memory it word print out RAM?
>
>
> Hello,
>
> Just out of curiosity, are you already familiar with Python's "lists"?
>
> If so, then you might want to try the slightly easier problem of pulling
> out acronyms out of a list of words.  Extracting an acronym out of a list
> like:
>
>     ["International", "Business", "Machines"]
>
>     ==> "IBM"
>
> is not too bad, and is one step toward doing the original problem on the
> phrase "International Business Machines".
>
>
> Tutorials like:
>
>     http://www.freenetpages.co.uk/hp/alan.gauld/tutseq2.htm
>
> and the other tutorials on:
>
>     http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
>
> should talk about lists.  Please feel free to ask questions here!
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



More information about the Tutor mailing list