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 str.title() :

"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:

map(str.title, list_of_strs)

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.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.