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 <[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:
  
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to