Skip to content
Advertisement

Tag: title-case

Titlecasing a string with exceptions

Is there a standard way in Python to titlecase a string (i.e. words start with uppercase characters, all remaining cased characters have lowercase) but leaving articles like and, in, and of lowercased? Answer There are a few problems with this. If you use split and join, some white space characters will be ignored. The built-in capitalize and title methods do

Advertisement