How to Use String casefold() Method in PythonPython Basics


The casefold() method converts strings to casefolded format for caseless matching.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

str = "AaABB"
print (str.casefold())

str = "HELLO WORLD"
print (str.casefold())

Output:

str:  aaabb
str:  hello world

Syntax

str.casefold()

Parameters

The method doesn’t take any parameters.

Return Value

It returns the casefolded string, i.e. the string converted to lower case.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us