Monday, 27 May 2019

Python program to convert surname into initials of a full name

# 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
>>>
"""



1 comment:

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(...