Clean Title Case
This kind of formatting is often used for article titles, book names, and UI cards. Write title_case, which turns the string title into a clean title: each word starts with a capital letter, except words listed in minor. The first word must always start with a capital letter, even if it appears in minor, and the original casing should be ignored.
Примеры
Ввод
"a clash of KINGS", "a an the of"Вывод
"A Clash of Kings"Ввод
"THE WIND IN THE WILLOWS", "The In"Вывод
"The Wind in the Willows"Ввод
"the quick brown fox"Вывод
"The Quick Brown Fox"Нужно реализовать
def title_case(title: str, minor: str = '') -> str:
Теги
strings
Idħol biex tara l-istorja tas-sottomissjonijiet
IdħolIdħol biex tuża l-Mentor tal-AI
IdħolVisible tests
1
Input
"a clash of KINGS", "a an the of"Expected
"A Clash of Kings"2
Input
"THE WIND IN THE WILLOWS", "The In"Expected
"The Wind in the Willows"3
Input
"the quick brown fox"Expected
"The Quick Brown Fox"4
Input
""Expected
""5
Input
"first", "first"Expected
"First"6
Input
"a clash of KINGSa clash of KINGS", "a"Expected
"A Clash Of Kingsa Clash Of Kings"Focus radio
Paused · SomaFM · Fluid