/  Technology   /  How do I lowercase a string in Python?
Datascience in car technology

How do I lowercase a string in Python?

How do I lowercase a string in Python?

 

In this article we’ll discuss two different ways of lowercase conversion of any given string

  • Using lower()
  • Using casefold()

 

Using lower():

The standard method available in Python which converts the uppercase string to lowercase is the string method lower(). It takes no parameters and returns the string with all the characters in lowercase. If there are no uppercase characters then it returns the original string only. 

This method is supported by both Python 2 and Python 3 versions.

 

Using casefold():

A new method named casefold() was introduced in Python 3. It works much similar to the lower() method. 

This method is much more stronger and aggressive than lower() which means it converts more characters into lower case and will find more comparisons while comparing any two given strings. This method removes all case distinctions from a string. 

We directly call this method using string. It doesn’t take any parameters and returns a string converted to lowercase.

Leave a comment