471,330 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

acronym program

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

thx
Sep 21 '07 #1
2 4880
Shawn Minisall <tr********@gmail.comwrites:
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]

Sep 21 '07 #2
That was it! Thanks a lot!

I was also trying to output the acronym in caps so I was entering
string.upper (acronym) like whats in the book and kept getting a
"'tuple' object is not callable" error message. Just for the heck of it
I tried it acronym.upper() and it worked! I thought it could work both
ways?

Paul Rudin wrote:
Shawn Minisall <tr********@gmail.comwrites:

>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]

Sep 21 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by ng4rrjanbiah | last post: by
89 posts views Thread by Tak-Shing Chan | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.