Create name_format.py
This commit is contained in:
20
2/2.12/2.12 Name Format/name_format.py
Normal file
20
2/2.12/2.12 Name Format/name_format.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
def output_format_one(first, middle, last):
|
||||||
|
_format = "{0}, {1}.".format(last, first[0])
|
||||||
|
return _format
|
||||||
|
|
||||||
|
def output_format_two(first, middle, last):
|
||||||
|
_format = "{0}, {1}.{2}.".format(last, first[0], middle[0])
|
||||||
|
return _format
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
name = input("Input your name: ")
|
||||||
|
|
||||||
|
name = name.split(' ')
|
||||||
|
|
||||||
|
if len(name) == 2:
|
||||||
|
name = output_format_one(name[0], None, name[1])
|
||||||
|
elif len(name) == 3:
|
||||||
|
name = output_format_two(name[0], name[1], name[2])
|
||||||
|
|
||||||
|
print(name)
|
||||||
Reference in New Issue
Block a user