4 ms·
It's tricky, but that's why nearly all of the time, you should use standard libraries. E.g., in Python, ".upper()" and ".capitalize()" does the work for you.
by ks2048 2y ago
It's tricky, but that's why nearly all of the time, you should use standard libraries. E.g., in Python, ".upper()" and ".capitalize()" does the work for you.
- f1shy 2y agoDoes it have titleize() ?
- ks2048 2y agoThat 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
- o11c 2y agoIt's `.title()`, but note that it doesn't follow language-specific semantic rules like not capitalizing "the" and "of".
- deleted 2y ago[deleted]