Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- 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 seperating them.
- It should look like this:
- Sam Harris => S.H
- Patrick Feeney => P.F
- '''
- def abbreviateName(name):
- firstLetter = name[0]
- indexOfSpace = -1000
- for i in range(0, len(name)):
- if name[i] == ' ':
- indexOfSpace = i
- secondLetter = name[indexOfSpace+1]
- return (firstLetter.upper() + "." + secondLetter.upper())
- # MAIN FUNCTION
- name = input("Give me a name: ")
- print(abbreviateName(name))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement