August 31, 2025
Capitalize first character of each word in a string in Python
You can convert first character in upper case of each word in a string with using title function, but also lowercases the rest of each word. We need to call title() function on string variable or object. title function takes no argument. Example code is mentioned below:
Code
greetingStr = "good morning"
result = greetingStr.title()
print(result) # print: Good Morning