1# Python string capitalization
2string = "this isn't a #Standard Sntence."
3string.capitalize() # "This isn't a #standard sentence."
4string.upper() # "THIS ISN'T A #STANDARD SENTENCE."
5string.lower() # "this isn't a #standard sentence."
6string.title() # "This Isn'T A #Standard Sentence."
7
8# ---------- Alternate Title Case ----------
9# "This Isn't A #standard Sentence."
10
11from string import capwords
12string = capwords(string) # capitalize characters after each separator.
13# see the doc: string.capwords(s, sep=None), separator defaults to space
14
15# or implement it directly:
16string = " ".join(s.capitalize() for s in string.split())
17#
1sample_text = "this is a sample string"
2result = sample_text.title() # "This Is A Sample String"