DEV Community

loading...

Discussion on: Daily Challenge #38 - Middle Name

Collapse
easyaspython profile image
Dane Hillard
def initialize(full_name):
    names = full_name.split()
    return ' '.join(
        f'{name[0]}.' if index > 0 and index < len(names) - 1 else name
        for index, name in enumerate(names)
    )