Capitalize First Letter of Each Word
Capitalize the first letter of each word in a sentence.
BeginnerTopic: String Programs
Python Capitalize First Letter of Each Word Program
This program helps you to learn the fundamental structure and syntax of Python programming.
# 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
Understanding Capitalize First Letter of Each Word
We use .title() which capitalizes the first character of each word and lowercases the rest.
Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.