100% found this document useful (2 votes)
4K views1 page

6.6 LAB Name Format

This document provides a program that takes a person's first name, middle name, and last name as input and outputs it in a standardized last name, first initial.middle initial format. It checks the length of the input to determine if it contains a middle name, and constructs the output string accordingly, placing the last name first followed by a comma and then the first and middle initials with periods in between.

Uploaded by

CHRIS D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
4K views1 page

6.6 LAB Name Format

This document provides a program that takes a person's first name, middle name, and last name as input and outputs it in a standardized last name, first initial.middle initial format. It checks the length of the input to determine if it contains a middle name, and constructs the output string accordingly, placing the last name first followed by a comma and then the first and middle initials with periods in between.

Uploaded by

CHRIS D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

6.

6 LAB Name format


Many documents use a specific format for a person's name. Write a program whose input
is:
firstName middleName lastName
and whose output is:
lastName, firstInitial.middleInitial.
Ex: If the input is:
Pat Silly Doe
the output is:
Doe, P.S.
If the input has the form:
firstName lastName
the output is:
lastName, firstInitial.
Ex: If the input is:
Julia Clark
the output is:
Clark, J.

complete_name=input().split()

length=len(complete_name)

if length==3:

print(complete_name[2]+", "+complete_name[0][0]+"."+complete_name[1][0]+".")

if length==2:

print(complete_name[1]+", "+complete_name[0][0]+".")

You might also like