缩写词是由一个短语中每个单词的第一个字母组成,均为大写。例如,CPU是短语“central processing unit”的缩写。
def acronym(phrase):
phrase = phrase.title()
text = phrase.strip(' ').split()
l = []
for i in text:
l.append(i[0])
s = ''.join(l)
return s
phrase=input()
print(acronym(phrase))
输入样例:
central processing unit
输出样例:
CPU