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.
Syntax
The syntax of String casefold() method in Python is
</>
Copy
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
</>
Copy
x = 'Hello World!'
result = x.casefold()
print(result)
Output
hello world!
String is already Lowercase
If the given string already contains only lowercase letters, then str.casefold() does nothing.
Example.py
</>
Copy
x = 'hello world!'
result = x.casefold()
print(result)
Output
hello world!
Conclusion
In this Python Tutorial, we learned how to convert characters in string to lowercase using String method – casefold().