Python String Casefold Method

In python, the string casefold() method is useful to convert the given string characters to lowercase, and it's same as the lower() method, but the difference is the casefold() method is more aggressive while converting the strings characters into lower case and find more matches when compare two strings.

String Casefold Method Syntax

Following is the syntax of defining a string casefold method in python.

 

string.casefold()

The python casefold method will not accept any parameters.

String Casefold Method Example

Following is the example of converting the given string characters to lowercase using the string casefold() method in python.

 

msg1 = "HI Guest HI"
print(msg1.casefold())
msg2 = "welcome to tutlane"
print(msg2.casefold())
msg3 = "2LEARN PYTHON"
print(msg3.casefold())

If you observe the above example, we are converting the given string characters to lowercase using the casefold() method.

 

When you execute the above python program, you will get the result as shown below.

 

hi guest hi
welcome to tutlane
2learn python

This is how you can use the string casefold() method in python to convert the given string characters to lowercase based on your requirements.