How to title case each word in Python?
Sometimes you need to change the case of the words in a given string. For instance, you get an input which represents the first name and the last name, and you want to make sure it is correctly capitalized.
Python has the title()
method that changes each word to title case (each word begins with a capital letter.)
name = "joe doe"
print(name) # prints joe doe
print(name.title()) # prints Joe Doe