How to convert string to Title Case in Python?

The Solution to How to convert string to Title Case in Python? is


Why not use title Right from the docs:

>>> "they're bill's friends from the UK".title()
"They'Re Bill'S Friends From The Uk"

If you really wanted PascalCase you can use this:

>>> ''.join(x for x in 'make IT pascal CaSe'.title() if not x.isspace())
'MakeItPascalCase'

~ Answered on 2011-12-01 19:33:25


Most Viewed Questions: