缩写词是由一个短语中每个单词的第一个字母组成,均为大写。例如,CPU是短语“central processing unit”的缩写。

函数接口定义:

acronym(phrase);
phrase是短语参数,返回短语的缩写词
 

裁判测试程序样例:


/* 请在这里填写答案 */
 

phrase=input()
print(acronym(phrase))

输入样例:

central  processing  unit
 

输出样例:

CPU
1 # 缩写词
2 # Author: cnRick
3 # Time  : 2020-4-12
4 def acronym(phrase):
5     wordsList = phrase.split()
6     result = []
7     for word in wordsList:
8         result.append(word[0].upper())
9     return "".join(result)

 

 

相关文章:

  • 2021-09-10
  • 2021-12-15
  • 2021-11-28
  • 2021-09-28
  • 2021-11-02
  • 2021-12-30
  • 2022-02-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-05-28
  • 2022-01-04
  • 2021-05-23
  • 2021-07-03
相关资源
相似解决方案