Forwarding to tutor ---------- Forwarded message ---------- Date: Mon, 26 Sep 2005 08:32:02 -0500 From: Jason Massey <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> wrote: > > > On Sat, 24 Sep 2005 [EMAIL PROTECTED] 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@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor