Capitalize First Letter of Each Word

Capitalize the first letter of each word in a sentence.

PythonBeginner
Python
# Program to capitalize first letter of each word

s = input("Enter a sentence: ")

result = s.title()

print("Title case:", result)

Output

Enter a sentence: hello world
Title case: Hello World

We use .title() which capitalizes the first character of each word and lowercases the rest.