Python - Convert String to Lowercase - Examples


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

The syntax to use lower() method is:

mystring.lower()

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

Examples

1. Convert given string (with some uppercase characters) 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)

Output

Original String : Python Examples
Lowercase String : python examples

2. Convert given string (with all uppercase characters) 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)

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.