acronym program

Paul Rudin paul.nospam at rudin.co.uk
Fri Sep 21 11:03:45 EDT 2007


Shawn Minisall <trekker182 at gmail.com> writes:

> I'm trying to write a program that gets the first letter of every word
> of a phrase and prints it on screen.  I'm having problems with it.
> I'm thinking a for loop would be good since I don't know the exact
> number of words the user is going to enter, but after that I get
> confused.  How do I tell python to just goto the beg of each word in
> the phrase and include it in the acronym?  Am I on the right track?
>
>    for a in string.split(phrase)
>    acronym = phrase [0]
>    acronym = acronym + 1


How about:

for a in phrase.split():
    print a[0]






More information about the Python-list mailing list