The Wayback Machine - https://web.archive.org/web/20250119103006/https://www.geeksforgeeks.org/python-string-lower/
Open In App

Python String lower() Method

Last Updated : 06 Nov, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The lower() method in Python converts all uppercase letters in a string to their lowercase. This method does not alter non-letter characters (e.g., numbers, punctuation).

Let’s start with a simple example of lower() method:

Python
s = "HELLO, WORLD!"

# Change all uppercase letters to lowercase
res = s.lower()
print(res)

Output
hello, world!

Syntax of lower() method

string.lower()

Parameters

  • This method does not take any parameters.

Return Type

  • The lower() method returns a new string with all uppercase characters converted to lowercase. The original string remains unchanged since strings in Python are immutable.

Example of lower() method

Let’s take an example to illustrate how lower() method works on a string that includes non-alphabetic characters.

Python
s = "Hello, World! 123 @Python"

# Change only uppercase letters to lowercase
res = s.lower()
print(res)

Output
hello, world! 123 @python

Explanation: The lower() method converts all uppercase letters in a string to lowercase, while leaving numbers and special characters unchanged.

Practical applications of lower()

The lower() method is very useful in various scenarios, such as making case-insensitive comparisons between strings.

Example: Case-Insensitive Comparison

Python
s1 = "Python"
s2 = "python"

if s1.lower() == s2.lower():
    print("The strings are equal.")
else:
    print("The strings are not equal.")

Output
The strings are equal.

Explanation: In this example, we convert both s1 and s2 to lowercase using lower() before comparing them. This approach ensures that the comparison is not affected by case differences.

Frequently Asked Questions on lower() Method

What is lower() method in Python?

The lower() method is a built-in Python string method that converts all uppercase letters in a string to lowercase. It returns a new string and does not change the original string.

Does lower() modify the original string?

No, lower() returns a new string where all characters are lowercase, but the original string remains unchanged because strings in Python are immutable.

Does lower() affect non-alphabet characters?

No, lower() only converts uppercase letters to lowercase. Non-alphabet characters (such as numbers, punctuation, or symbols) remain unchanged.

What is return type of lower() method?

The return type is a str, specifically a new string in lowercase.


Next Article
Practice Tags :

Similar Reads

three90RightbarBannerImg