2 ms·
That is capitalize() There's a note in the docs [0], Changed in version 3.8: The first character is now put into titlecase rather than uppercase. This mea
by ks2048 2y ago
That is capitalize()
There's a note in the docs [0],
Changed in version 3.8: The first character is now put into titlecase rather than uppercase. This means that characters like digraphs will only have their first letter capitalized, instead of the full character.
[0] https://docs.python.org/3/library/stdtypes.html#str.capitalize https://docs.python.org/3/library/stdtypes.html#str.capitali...
EDIT:
As the other reply says, ".title()" is probably a better answer to your question. Warning as the docs show [1], this splits things on sequence of letters, not whitespace!
>>> "they're bill's friends from the UK".title()
"They'Re Bill'S Friends From The Uk"
[1] https://docs.python.org/3/library/stdtypes.html#str.title https://docs.python.org/3/library/stdtypes.html#str.title