Title Case Without .title()
Capitalize the first letter of every word in a sentence, without using the built-in .title() method.
Approach: split the sentence into words, capitalize each word manually (word[0].upper() + word[1:].lower()), and join them back together with spaces.
Input: One line: a sentence.
Output: One line: the same sentence with the first letter of every word capitalized.
the quick brown fox
The Quick Brown Fox
- 1 <= number of words <= 200
Hint 1
word[0] is the first character, word[1:] is everything after it.
Hint 2
word[0].upper() + word[1:].lower() capitalizes a single word without .title().
Hint 3
" ".join(result) puts the words back together with single spaces between them.
Split the sentence into a list of words, then rebuild each word manually as word[0].upper() + word[1:].lower() — the first character upper-cased, the rest lower-cased. Joining the capitalized words back with " ".join(...) reproduces exactly what .title() would have done, without calling it.