Python string lower() method explanation with example

Python string lower() method explanation with example:

Python string comes with a lot of different methods and lower() is one of them. This function can be used to convert a string to lowercase. In this post, we will learn how to use lower() with examples.

Syntax of lower() :

The syntax of lower() method is as below:

string.lower()

Parameter and return values:

This method doesn’t take any parameter. It returns one string converting of all characters of the string to lowercase. It returns the same string if no uppercase character is found.

Example of lower():

Below program shows how to use lower():

given_str = "Hello World !!"

print(given_str.lower())

It will print:

hello world !!

Convert a string to lower case by taking user input:

We can also take one string as input from the user and convert it to lower using lower() method:

given_string = input("Enter a string : ")

print("Lowercase : {}".format(given_string.lower()))

It will print output as like below:

Enter a string : Hello  World 123
Lowercase : hello  world 123

You might also like: