Home » Python String | casefold() method with Examples

Python String | casefold() method with Examples

by Online Tutorials Library

Python String Casefold() Method

Python 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”.

Signature

Parameters

No parameter is required.

Return Type

It returns lowercase string.

Python Version

This function was introduced in Python 3.3.

Python String Casefold() Method Example 1

Output:

Old value: TutorAspire New value: TutorAspire 

Python String Casefold() Method Example 2

The strength of casefold, it not only converts into lowercase but also converts strictly. See an example below ‘β’ is converted into “ss”.

Output:

Old value: TutorAspire - β  New value: TutorAspire ? ss  

Python String Casefold() Method Example 3

If string is in camelcase, it still converts whole string into lowercase.

Output:

Old value: TutorAspire New value: TutorAspire 

Next TopicPython Strings

You may also like