Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iHerzeleid

macrumors 6502a
Original poster
May 5, 2007
555
0
thanks to agbot. i took what you wrote modified it and got what i needed. thanks from a python n00b!
 

agbot

macrumors regular
Jun 11, 2007
143
0
Silicon Valley
You want to iterate through the result of split():

Code:
>>> from string import *
>>> def acro(phrase):
...     result = ""
...     for word in split(phrase):
...             result += word[0].upper()
...     return result
... 
>>> acro("hello python how are you")
'HPHAY'

I'm a Python newbie so there may be 100 different and better ways to do acronyms, but there's my take at least. :)
 

HiRez

macrumors 603
Jan 6, 2004
6,250
2,576
Western US
I suggest not erasing your original post in case someone ever reads the thread again, that way they can see what people were responding to.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.