VOOZH about

URL: https://www.geeksforgeeks.org/python/python-string-casefold-method/

⇱ Python String casefold() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python String casefold() Method

Last Updated : 11 Apr, 2023

Python String casefold() method is used to convert string to lowercase. It is similar to the Python lower() string method, but the case removes all the case distinctions present in a string.

Python String casefold() Method Syntax

Syntax:  string.casefold()

Parameters: The casefold() method doesn't take any parameters.

Return value: Returns the case folded string the string converted to lower case.

Python String casefold() Method Example

Output:

lowercase string: geeksforgeeks

Difference between casefold() and lower() in Python

Python String casefold() Method is more aggressive in conversion to lowercase characters because it tends to remove all case distinctions in a String.

Output:

Using lower(): ß
Using casefold(): ss

Practical Example using Python String casefold() Method

Here, we have a Python String with characters of mixed cases. We are using the Python casefold() Method to convert everything to lowercase.

Output:

Original String: WeightAGE oF THe DiScuSSiON
String after using casefold(): weightage of the discussion
Comment
Article Tags:
Article Tags: