s = \'the brown fox\'
...do something here...
s should be:
\'The Brown Fox\'
What\'s the easiest
To capitalize words...
str = "this is string example.... wow!!!";
print "str.title() : ", str.title();
@Gary02127 comment, the below solution works with title with apostrophe
import re
def titlecase(s):
return re.sub(r"[A-Za-z]+('[A-Za-z]+)?", lambda mo: mo.group(0)[0].upper() + mo.group(0)[1:].lower(), s)
text = "He's an engineer, isn't he? SnippetBucket.com "
print(titlecase(text))