Shorten the Name
An acronym is a quick way to turn a long name into a few clear letters. The function acronym receives a string s, splits it into words, and builds a new string from the first letter of each word. Convert every letter in the result to uppercase.
Примеры
Ввод
"Portable Network Graphics"Вывод
"PNG"Ввод
"as soon as possible"Вывод
"ASAP"Ввод
"word"Вывод
"W"Нужно реализовать
def acronym(s: str) -> str:
Теги
strings
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
AnmeldenVisible tests
1
Input
"Portable Network Graphics"Expected
"PNG"2
Input
"as soon as possible"Expected
"ASAP"3
Input
"word"Expected
"W"4
Input
""Expected
""5
Input
"you only live once"Expected
"YOLO"6
Input
"elbissop sa noos sa"Expected
"ESNS"Focus radio
Paused · SomaFM · Fluid