# Python program to convert surname into initials of a full name
def initial(s):
# split the string into a list
l = s.split()
new = ""
# traverse in the list
for i in range(len(l)-1):
s = l[i]
# adds the capital first character
new += (s[0].upper()+'.')
# l[-1] gives last item of list l. We
# use title to print first character in
# capital.
new += l[-1].title()
return new
# Driver code
a ="alluri sitha rama raju"
print(initial(a))
"""output:
A.S.R.Raju
>>>
"""
def initial(s):
# split the string into a list
l = s.split()
new = ""
# traverse in the list
for i in range(len(l)-1):
s = l[i]
# adds the capital first character
new += (s[0].upper()+'.')
# l[-1] gives last item of list l. We
# use title to print first character in
# capital.
new += l[-1].title()
return new
# Driver code
a ="alluri sitha rama raju"
print(initial(a))
"""output:
A.S.R.Raju
>>>
"""
ReplyDeleteThis information is really awesome thanks for sharing most valuable information.
Python Training in Hyderabad
Python Training
Python Online Training
Python Course in Hyderabad
Python Institute in Hyderabad
Python Online Training in Hyderabad