runtime
103 / 500
question 103 String Algorithms · easy

An acronym from an organisation's name

A report lists organisations by their acronyms: Consumer Financial Protection Bureau is CFPB. Build the acronym from the first letter of each word, in capitals. Hyphens separate words too (Run-Length Encoding is RLE). The small words of, and, the, for are skipped, except when one is the first word.

Functionacronym(name)
Returnsthe capital first letters of the words, small words skipped unless first; "" for a name with no words
Wordsseparated by any whitespace or by -; small words are matched ignoring case
Examples
callacronym('Consumer Financial Protection Bureau')returns'CFPB'
callacronym('Bureau of Labor Statistics')returns'BLS'
callacronym('Run-Length Encoding')returns'RLE'

Loading your progress…

An acronym from an organisation's name — Python practice · Runtime