Is there any difference in str.title()
vs str.capitalize()
? My understanding from the docs is that both methods capitalize the first letter of a word and make the rest of the letters lowercase. Did anyone run into a situation where they cannot be used interchangeably?
title()
changes every word, but capitalize()
only the first word in a sentence:
>>> a = 'silly question'
>>> a.title()
'Silly Question'
>>> a.capitalize()
'Silly question'
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With