String casefold()
Python String casefold() method converts string into lower case.
In this tutorial, we will learn the syntax and examples for casefold() method of String class.
ADVERTISEMENT
Syntax
The syntax of String casefold() method in Python is
str.casefold()
Examples
Convert String to Lowercase
In this example, we will take a string, and converts this string into lower case using str.casefold() method.
Example.py
x = 'Hello World!' result = x.casefold() print(result)Try Online
Output
hello world!
String is already Lowercase
If the given string already contains only lowercase letters, then str.casefold() does nothing.
Example.py
x = 'hello world!' result = x.casefold() print(result)Try Online
Output
hello world!
Conclusion
In this Python Tutorial, we learned how to convert characters in string to lowercase using String method – casefold().