In this lesson, you’ll explore string methods that perform case conversion on the target string. These are the case conversion methods:
str.capitalize()
str.lower()
str.swapcase()
str.title()
str.upper()
Here’s how to use str.capitalize()
:
>>> s = 'egG BacOn SauSAGE loBSter'
>>> s.capitalize()
'Egg bacon sausage lobster'
>>> s = 'egg123#BACON#.'
>>> s.capitalize()
'Egg123#bacon#.'
Here’s how to use str.lower()
: