472,803 Members | 858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,803 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 4958
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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.