C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Python String Casefold() MethodPython Casefold() method returns a lowercase copy of the string. It is more simillar to lowercase method except it revomes all case distinctions present in the string. For example in German, 'β' is equivelent to "ss". Since it is already in lowercase, lowercase do nothing and prints 'β' whereas casefold converts it to "ss". Signaturecasefold() ParametersNo parameter is required. Return TypeIt returns lowercase string. Python VersionThis function was introduced in Python 3.3. Python String Casefold() Method Example 1# Python casefold() function example # Variable declaration str = "JAVATPOINT" # Calling function str2 = str.casefold() # Displaying result print("Old value:", str) print("New value:", str2) Output: Old value: JAVATPOINT New value: TheDeveloperBlog Python String Casefold() Method Example 2The strength of casefold, it not only converts into lowercase but also converts strictly. See an example below 'β' is converted into "ss". # Python casefold() function example # Variable declaration str = "JAVATPOINT - β" # Calling function str2 = str.casefold() # Displaying result print("Old value:", str) print("New value:", str2) Output: Old value: JAVATPOINT - β New value: TheDeveloperBlog ? ss Python String Casefold() Method Example 3If string is in camelcase, it still converts whole string into lowercase. # Python casefold() function example # Variable declaration str = "JaVaTpOiNt" # Calling function str2 = str.casefold() # Displaying result print("Old value:", str) print("New value:", str2) Output: Old value: JaVaTpOiNt New value: TheDeveloperBlog
Next TopicPython Strings
|