728x90
1. Problem: https://py.checkio.org/en/mission/convert-to-title-case/
2. My solutions
def to_title_case(sentence: str) -> str:
# your code here
return ' '.join([data.capitalize() for data in sentence.lower().split()])
print("Example:")
print(to_title_case("hello world"))
# These "asserts" are used for self-checking
assert to_title_case("hello world") == "Hello World"
assert to_title_case("openai gpt-4") == "Openai Gpt-4"
assert to_title_case("this is a title") == "This Is A Title"
assert to_title_case("THE QUICK BROWN FOX") == "The Quick Brown Fox"
assert to_title_case("JUMPs ovER a LAZy dog") == "Jumps Over A Lazy Dog"
assert to_title_case("typescript is great") == "Typescript Is Great"
assert to_title_case("the answer is 42") == "The Answer Is 42"
assert to_title_case("to be or not to be") == "To Be Or Not To Be"
assert to_title_case("that is the question") == "That Is The Question"
assert to_title_case("") == ""
728x90
'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글
[CheckIO/Scientific Expedition] Longest substring of unique characters (0) | 2024.02.18 |
---|---|
[CheckIO] Replace All Occureences (0) | 2024.02.18 |
[CheckIO] Count Vowels (0) | 2024.02.18 |
[Check IO] words-order (0) | 2022.02.27 |
[Check-IO] Conversion into CamelCase (0) | 2021.12.25 |
댓글