Capitalize First Letter of Each Word in Python
If you have a sentence containing multiple words, and you want each of the words to start with a capital letter, then you can do one of the following:
Option 1 - using string.capwords()
Output: 'This Is A Test!'
Option 2 - using title()
|
|
Output: 'This Is A Test!'
Option 3 - using join()
, split()
and list comprehensions
|
|
Output: 'This Is A Test!'