How does one convert an uppercase string to proper sentence-case? Example string:
"OPERATOR FAIL TO PROPERLY REMOVE SOLID WASTE"
Using titlecase(str)
gives me:
"Operator Fail to Properly Remove Solid Waste"
What I need is:
"Operator fail to properly remove solid waste"
Is there an easy way to do this?
The lower() method converts all uppercase characters in a string into lowercase characters and returns it.
The upper() method returns a string where all characters are in upper case. Symbols and Numbers are ignored.
The swapcase() method returns the string by converting all the characters to their opposite letter case( uppercase to lowercase and vice versa).
The String title() method in Python is used to convert the first character in each word to uppercase and the remaining characters to lowercase in the string and returns a new string.
Let's use an even more appropriate function for this: string.capitalize
>>> s="OPERATOR FAIL TO PROPERLY REMOVE SOLID WASTE" >>> s.capitalize() 'Operator fail to properly remove solid waste'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With