Python Program to Capitalize the First Letter of Each Word in Python Using string.capwords() Function
#Capitalize the First Letter of Each Word in Python Using string.capwords()
import string
s = "python is the most popular programming language"
print("Original string: " +s)
print("After capitalizing the first letter:")
#string.capwords() method converts each word's first letter to uppercase, giving the desired output.
result = string.capwords(s)
print(result)
Output:
Original string: python is the most popular programming language
After capitalizing the first letter: Python Is The Most Popular Programming Language
About The Author
I have more than 6 years of experience in the IT industry, and I have built a solid foundation in the creation and upkeep of online applications. I have constantly shown strong work ethics, self-motivation, and an aptitude for learning quickly throughout my career.