Abbreviations are made up of the first letter of each word in a phrase , All in capitals . for example ,CPU It's a phrase “central processing unit” Abbreviation .
Function interface definition :
acronym(phrase);
phrase Is a phrase parameter , Returns the abbreviation of the phrase
Sample referee test procedure :
/* Please fill in the answer here */
phrase=input()
print(acronym(phrase))
sample input :
central processing unit
sample output :
CPU
def acronym(phrase):
phrase=phrase.upper()# Capitalize
first=""# An empty string
first+=phrase[0]# The first extra treatment
leng=len(phrase)
for i in range(leng):
if(phrase[i]==" " and phrase[i+1]!=" "):# The space becomes a letter, which is the beginning of the word
first+=phrase[i+1]# Add with string
return first