Answer to Question #223969 in Python for Anand

Question #223969
Acronyms

You are given some abbreviations as input. Write a program to print the acronyms separated by a dot(

.) of those abbreviations.

Input

The first line of input contains space-separated strings.

Explanation

Consider the given abbreviation, 

Indian Administrative Service. We need to consider the first character in each of the words to get the acronym. We get the letter I from the first string Indian, we get the letter A from the second word Administrative, and we get the letter S from the third word Service. So, the final output should be I.A.S.

Sample Input 1
Indian Administrative Service
Sample Output 1
I.A.S
Sample Input 2
Very Important Person
Sample Output 2
V.I.P

1
Expert's answer
2021-08-09T02:34:38-0400




def Acronym(first):
    code  = list(first.split( )) 
    
    stat = " "
    for x in code:
        stat +=(x[0]+".")
        
    s = len(stat)
    finalAnswer = " "
    for i in range(0, s-1):
        finalAnswer += stat[i]
        
    return finalAnswer
print("Sample Input 1")    
first =  "Indian Administrative Service"
print(first)
print("Sample Output 1") 
print(Acronym(first))


print("Sample Input 2")    
second =  "Very Important Person"
print(second)
print("Sample Output 2") 
print(Acronym(second))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS