Capitalize First Letter of Each Word

Capitalize first letter of each word.

IntermediatePhase 5 - Category 3: Word OperationsExample 6 of 10
capitalize-first-letter-of-each-word.py
1# Take string input
2s = input("Enter a string: ")
3
4# Capitalize first letter of each word
5result = s.title()
6print(f"Capitalized: {result}")

Output

Enter a string: hello world
Capitalized: Hello World

What's going on

Use title() method to capitalize.

Key Concepts:

title() capitalizes first letter of each word
Returns new string
Simple one-line solution