Python Gem #4: str.title
You know about
str.lower(), str.upper(), str.capitalize()right?
"ThIS".lower() --> "this"
"ThIS".upper() --> "THIS"
"ThIS".capitalize() -> "This"
Well, what if you want to Uppercase The Start Of Every Word? That’s where we use
"this is Pretty cOOL".title() --> "This Is Pretty Cool"
str methods can be use as class methods too! This is helpful when using the map function:
This is a daily series called Python Gems. Each short posts covers a detail or a feature of the python language that you can use to increase your codes readability while decreasing its length.