Phrase to Acronym
Long names are often shortened into acronyms, so Portable Network Graphics becomes PNG. The function abbreviate receives a phrase and builds an acronym from the first letter of each word. Words may be separated by spaces or hyphens, apostrophes should be ignored, and the result should be uppercase.
Примеры
Ввод
"Portable Network Graphics"Вывод
"PNG"Ввод
"Ruby on Rails"Вывод
"ROR"Ввод
"Complementary metal-oxide semiconductor"Вывод
"CMOS"Нужно реализовать
def abbreviate(words: str) -> str:
Теги
strings
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänVisible tests
1
Input
"Portable Network Graphics"Expected
"PNG"2
Input
"Ruby on Rails"Expected
"ROR"3
Input
"Complementary metal-oxide semiconductor"Expected
"CMOS"4
Input
"The Road _Not_ Taken"Expected
"TRNT"5
Input
"Halley's Comet"Expected
"HC"6
Input
""Expected
""Focus radio
Paused · SomaFM · Fluid