小弟有一个python问题。跪求好心人帮助!急急急!!!
Part3:Acronyms(第3部分:首字母缩写词)Writeaprogram(inafilecalledacronyms.py)thatasksauserforaph...
Part 3: Acronyms
(第3部分:首字母缩写词)
Write a program (in a file called acronyms.py) that asks a user for a phrase and prints the acronym of that phrase. You program should ignore the words the, of, and at. Here are some examples:
(写一个程序(一个名为acronyms.py),要求用户一个短语,并打印出这句话的缩写。你的程序应该忽略的话,,和。下面是一些例子:)
input output
University of British Columbia UBC
Alexander College AC
Simon Fraser University SFU
Massachusetts Institute of Technology MIT
See you later syl
Be right back brb
Talk to you later ttyl 展开
(第3部分:首字母缩写词)
Write a program (in a file called acronyms.py) that asks a user for a phrase and prints the acronym of that phrase. You program should ignore the words the, of, and at. Here are some examples:
(写一个程序(一个名为acronyms.py),要求用户一个短语,并打印出这句话的缩写。你的程序应该忽略的话,,和。下面是一些例子:)
input output
University of British Columbia UBC
Alexander College AC
Simon Fraser University SFU
Massachusetts Institute of Technology MIT
See you later syl
Be right back brb
Talk to you later ttyl 展开
展开全部
你好!我已经帮你写好了程序,如下:
phrase = raw_input("Enter a phrase: ")
words = phrase.split(" ")
letters = []
for i in words:
if i == "the" or i == "at" or i == "of":
words.remove(i)
for i in words:
letters.append(i[0])
print "".join(letters)
希望可以帮助你,如果你有其他要求或者疑问,可以追问,望采纳!
phrase = raw_input("Enter a phrase: ")
words = phrase.split(" ")
letters = []
for i in words:
if i == "the" or i == "at" or i == "of":
words.remove(i)
for i in words:
letters.append(i[0])
print "".join(letters)
希望可以帮助你,如果你有其他要求或者疑问,可以追问,望采纳!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询