loading...

re: Daily Challenge #38 - Middle Name VIEW POST

FULL DISCUSSION
 

Python

def initialize_names(name):
    name= name.split(' ')
    if len(name) <=2:   return ' '.join(name)
    new_name=[]
    for i in range(len(name)):
        if i != 0 and i != (len(name)-1):    new_name.append(name[i][0]+'.')
        else:   new_name.append(name[i])
    return ' '.join(new_name)
code of conduct - report abuse