def acronym(s):
return ''.join([x[0] for x in s.split(' ')])
#here split(' ') will break all the words into a list.
#x[0] will take the first letters of all words.
#finally join will again convert it to a string from a list
print(acronym('The State Department'))
'TSD'
2
Lovish Yadav
On
# function to create acronym
def fxn(stng):
# add first letter
oupt = stng[0]
# iterate over string
for i in range(1, len(stng)):
if stng[i - 1] == ' ':
# add letter next to space
oupt += stng[i]
# uppercase oupt
oupt = oupt.upper()
return oupt