Editor

Initials

#202 · Strings · Beginner · 25 XP · about 4 min

Write initials(name) that returns the initials of a name: the first letter of each word, as a capital, each followed by a full stop.

Words are separated by spaces, and there may be extra spaces at the start, at the end or between words. A hyphenated name like jean-luc counts as one word. If name has no words at all, return an empty string.

Examples

initials("ada lovelace")                  # returns 'A.L.'
initials("Grace Brewster Murray Hopper")  # returns 'G.B.M.H.'
initials("  alan   turing ")              # returns 'A.T.'

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.