473,387 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 4987
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ng4rrjanbiah | last post by:
<ABBR title="foo">f</ABBR> Just consider the situation like the above. If we use such markup, search engines (tried only Google) don't access the "foo". Is there anyway to make it accessible for...
10
by: Jarson | last post by:
I am using the ACRONYM tag to provide an explanation of codes within my application. Example: <p>The circuit <acronym title="Circuit P123T: Picton SS to Telebary SS 345KV">P123T</acronym> is...
89
by: Tak-Shing Chan | last post by:
Dear c.l.c regulars, How about codifying a list of acceptable acronyms on c.l.c? <g> <g,d&r> <VBG> AAMOF AFAIAA AFAIAC
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.