473,405 Members | 2,210 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,405 software developers and data experts.

python acronym output

I am trying to output an acronym in python. I keep getting a syntax error on the first line and can't figure it out. Any help would be appreciated. I'm a newbie to programming.
Expand|Select|Wrap|Line Numbers
  1. #A Program to Display an Acronym
  2. #By Betty Kaiman
  3.  
  4. def acronym_phrase():
  5.     phrase = (input("Give a phrase: ")
  6.     words = phrase.split()
  7.     acronym = ""
  8.         for ch in phrase":
  9.         print ("Character:", ch)
  10.     for words in phrase.split[';'0,13,21,28]
  11.               for ch in phrase.split[0]
  12.     print ("The acronym is", acronym)
  13.  
  14. acronym_phrase
Feb 20 '12 #1
3 6348
bvdet
2,851 Expert Mod 2GB
You are missing a parenthesis at the end of the line.
Feb 20 '12 #2
dwblas
626 Expert 512MB
Do you want the variable "words" to be
words = phrase.split()
or
for words in phrase.split[';'0,13,21,28]
Start with this
Expand|Select|Wrap|Line Numbers
  1. def acronym_phrase():
  2.     phrase = input("Give a phrase: ")
  3.     words = phrase.split()
  4.     for each_word in words:
  5.         print each_word[0], each_word
  6. acronym_phrase() 
Feb 21 '12 #3
Smygis
126 100+
Expand|Select|Wrap|Line Numbers
  1. def acronymPhrase(phrase):
  2.  
  3.     return "".join([x[0] for x in phrase.split()])
  4.  
  5. if __name__ == "__main__":
  6.  
  7.     print (acronymPhrase(raw_input("Give a phrase: ")))
Expand|Select|Wrap|Line Numbers
  1. Give a phrase: I Am A Little Bee
  2. IAALB
  3. >>> 
Not sure what "for words in phrase.split[';'0,13,21,28]" does.
Feb 21 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: temp1111 | last post by:
Hi Further to my earlier post we're getting the following output when embedding a python application in C++ If there is any obvious cause please let us know. The version of python is 2.2.1
4
by: Avi Kak | last post by:
Is there a Python function in any of the standard-distribution modules that does what the backticks do in Perl? I want to run an external command and I'd like its output to be captured directly...
10
by: A.M | last post by:
Hi, I am having difficulty with shell scripting in Python. I use the following command to run a DOS command and put the return value in a Python variable:
2
by: Pan Xingzhi | last post by:
Guys: Hi there. Recently I'll have to write a quite interesting program in Python on a Linux box. What I need is a function which allows the user to 'switch' the audio output from <an audio...
3
by: morris.slutsky | last post by:
So every now and then I like to mess around with hobby projects - I often end up trying to write an OpenGL video game. My last attempt aborted due to the difficulty of automating game elements and...
4
by: yinglcs | last post by:
Hi, I use os.system() to execute a system command in python. Can you please tell me how can I parse (in python) the output of the os.system() ? Thank you.
7
by: Chi Yin Cheung | last post by:
Hi, Is there a way in python to output binary files? I need to python to write out a stream of 5 million floating point numbers, separated by some separator, but it seems that all python supports...
4
by: John Nagle | last post by:
I'm printing out each entry in "gc.garbage" after a garbage collection in DEBUG_LEAK mode, and I'm seeing many entries like <cell at 0x00F7C170: function object at 0x00FDD6B0> That's the...
1
by: lqnt1981 | last post by:
Following is the code in python that opens all files under a directories and puts a comma in place of whitespace, I can see the output on the command line, but I am not sure what to do in order to...
4
by: Grant Edwards | last post by:
When I ssh in to my Windows XP box and run Python apps, output from "print" and and "sys.stdout.write()" is being buffered so that none of the output shows up until the program exits. From...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.