DEV Community

loading...

Discussion on: Daily Challenge #38 - Middle Name

Collapse
shiroihana013 profile image
ShiroiHana013
def initializeName(name: str):
    name = name.split(" ")
    if (len(name) >= 3):
        #loop from first name to last name.
        for i in range(1, len(name)-1):
            name[i] = name[i][0] + "."
    name = ' '.join(name)
    return name