tryng to make a python acronym maker

Discussion in 'Mac Programming' started by iHerzeleid, Feb 8, 2008.

  1. macrumors 6502a

    iHerzeleid

    Joined:
    May 5, 2007
    #1
    thanks to agbot. i took what you wrote modified it and got what i needed. thanks from a python n00b!
     
  2. macrumors regular

    Joined:
    Jun 11, 2007
    Location:
    Silicon Valley
    #2
    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. :)
     
  3. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #3
    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.
     

Share This Page