-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabbrev_name.py
More file actions
19 lines (17 loc) · 771 Bytes
/
abbrev_name.py
File metadata and controls
19 lines (17 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Description:
# Write a function to convert a name into initials. This kata strictly takes two words with one space in between them.
# The output should be two capital letters with a dot separating them.
# Examples:
# Sam Harris => S.H
# Patrick Feeney => P.F
def abbrev_name(name):
# Split up the string into a list by splitting it between the space
wordList = list(name.split(" "))
print(wordList)
# Create the variable that will be returned. Create the variable via the first character of each object in the list
# with a period in the middle
abbreviation = (wordList[0][0] + "." + wordList[1][0])
# Force the variable to be all uppercase
abbreviation = abbreviation.upper()
# Return the finished variable
return abbreviation