Python Convert String to Lowercase

Python String to Lowercase

Sometimes there could be scenarios where we may need to convert the given string to lowercase as a step in pre-processing.

To convert String to lowercase, you can use lower() method on the String. In this tutorial, we will learn how to transform a string to lowercase.

Python String to Lowercase

Syntax of String.lower() method

The syntax to use lower() method is:

mystring.lower()
Run

String.lower() function returns a string with all the characters of this string converted to lower case.

Example 1: Convert String to Lowercase

Following is an example python program to convert a string to lower case.

Python Program

mystring = 'Python Examples'
print('Original String :',mystring)

lowerstring = mystring.lower()
print('Lowercase String :',lowerstring)
Run

Output

Original String : Python Examples
Lowercase String : python examples

Example 2: Convert String to Lowercase

In this example, we take a string with all uppercase alphabets. And convert the string to lowercase.

Python Program

mystring = 'HTTPS://PYTHONEXAMPLES.ORG'
print('Original String :',mystring)

lowerstring = mystring.lower()
print('Lowercase String :',lowerstring)
Run

Output

Original String : HTTPS://PYTHONEXAMPLES.ORG
Lowercase String : https://pythonexamples.org

Summary

In this tutorial of Python Examples, we learned to transform a given string to lowercase using string.lower() method, with the help of well detailed examples.