Capitalize First Letter of Each Word
Apply title casing to entered text. Students inspect uppercased starts, lowercased remaining letters, and why title is not simply a first-letter-only operation.
1# Take string input2s = input("Enter a string: ")34# Capitalize first letter of each word5result = s.title()6print(f"Capitalized: {result}")
Output
Enter a string: hello world Capitalized: Hello World
In this one
- Apply title-case mappings
- Understand inner-case changes
- Recognize word-boundary rules
How it works
- 1
Read the response unchanged.
- 2
Create result with s.title().
- 3
Print the returned title-cased text.
Edge cases
Does the method keep inner uppercase letters?
Does the method keep inner uppercase letters?
No. Following cased letters are generally lowercased.
Does empty input work?
Does empty input work?
Yes. The result is empty.
What's going on
s.title() returns title-cased text. It typically uppercases the start of each cased word segment and lowercases the following cased letters.
Thus hELLO becomes Hello, not HELLO. The method has its own word-boundary rules, including surprising apostrophe behavior, so it is not a grammar-aware title editor. Unlike split and join, it does not intentionally normalize all whitespace separators.
Does the method keep inner uppercase letters? No. Following cased letters are generally lowercased.
Does empty input work? Yes. The result is empty.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
What does hELLO become?
Pick an answer to check it.
Question 2
Does the method keep inner uppercase letters?
Pick an answer to check it.
Questions people ask
Does the method keep inner uppercase letters?
No. Following cased letters are generally lowercased.
Does empty input work?
Yes. The result is empty.
What does hELLO become?
Hello.
๐Related Content
- ๐
Phase 5 - Learn Concepts
Review Phase 5 concepts and explanations
- ๐
Phase 5 - Quiz
Test your Phase 5 understanding with quiz questions
- ๐ป
Phase 5 - All Practice Problems
Explore all practice problems for Phase 5
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum