tags:
- code
topic: String
difficulty: Easy
link: https://www.codewars.com/kata/57eadb7ecd143f4c9c0000a3/python
date: 2023-12-30
Problem
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.
`Sam Harris` => `S.H`
`patrick feeney` => `P.F`
def abbrev_name(name):
name = name.upper().split()
return name[0][0] + "." + name[1][0]
def abbrevName(name):
return '.'.join(w[0] for w in name.split()).upper()
def abbrevName(name):
first, last = name.upper().split(' ')
return first[0] + '.' + last[0]