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

Python String lower() Method

Last Updated : 05 Jan, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Python string lower() method converts all letters of a string to lowercase. If no uppercase characters exist, it returns the original string.

Example:

Python3




string = "ConvErT ALL tO LoWErCASe"
print(string.lower())


Output

convert all to lowercase

Syntax of String lower()

string_name.lower()

Parameters

The lower() method doesn’t take any parameters. 

Returns

Returns a lowercase string of the given string

What is the Python String lower() Method?

The `lower()` method is a string method in Python. When applied to a string, it converts all the characters in the string to lowercase.

This is useful for standardizing and comparing strings without considering case differences. For example, if the original string is “Hello World,” applying `lower()` would result in “hello world.” It is a commonly used method for case-insensitive string operations.

How to use the Python string lower() Method?

To convert all characters of a string to lowercase just call the lower() function with the string. lower() function is an in-built string method and can be used with variables as well as strings. Let’s understand it better with an example:

Python3




string="HelloWorld"
print(string.lower())
print("HelloWorld".lower())


Output

helloworld
helloworld

How to Convert a String to Lowercase in Python

There are various ways to Lowercase a string in Python but here we are using some generally used methods to convert a string to lowercase:

  • Using lower() Function
  • Using map() with Lambda Function in lower() Method
  • Using List Join with lower() Method
  • Using map and str.lower with lower() Method
  • Using Swapcase() Function 
  • Using casefold() Function

Convert string to lower case using lower() method

Let’s see two different cases of using the lower() method.

  • Strings with Alphabetic Characters
  • Strings with Alphanumeric Characters

String With Alphabetic Characters 

In this example, code initializes a string variable ‘text’ with the value ‘GeEks FOR geeKS’, then prints the original string. It subsequently converts the string to lowercase using the `lower()` function and prints the result, demonstrating the case transformation.

Python3




text = 'GeEks FOR geeKS'
 
print("Original String:")
print(text)
 
# lower() function to convert
# string to lower_case
print("\nConverted String:")
print(text.lower())


Output: 

Original String:
GeEks FOR geeKS
Converted String:
geeks for geeks

String with alphanumeric characters

In this example, the String with Alphanumeric Characters and code defines a string variable ‘text’ with a mixed case. It then prints the original string and, in the next section, prints the string converted to lowercase using the lower() function.

Python3




text = 'G3Ek5 F0R gE3K5'
 
print("Original String:")
print(text)
 
# lower() function to convert
# string to lower_case
print("\nConverted String:")
print(text.lower())


Output: 

Original String:
G3Ek5 F0R gE3K5
Converted String:
g3ek5 f0r ge3k5

Other Methods to Convert String to Lower Case

Let’s look at some other methods to convert a string to lowercase. There are multiple ways to complete a task in Python and we will discuss some lower() method alternatives below:

Convert String to lowercase using map With Lambda Function

In this example, the code converts the string “GeeksForGeeks” to lowercase using a lambda function and the map function. The result, “geeksforgeeks,” is then printed. The same can be achieved more succinctly with `lowercased_string = original_string.lower()`.

Python3




original_string = "GeeksForGeeks"
lowercased_string = ''.join(map(lambda x: x.lower(), original_string))
print(lowercased_string)


Output:

geeksforgeeks

Convert String to lowercase using List Join

In this example, the code converts the string “Pratham Sahani” to lowercase using a list comprehension. The resulting lowercase string is then joined and printed.

Python3




original_string = "Pratham Sahani"
lowercased_string = ''.join([c.lower() for c in original_string])
print(lowercased_string)


Output :

pratham sahani

Convert String to lowercase using map and str.lower with lower() Method

In this example, the code converts the original string “GeeksforGeeks” to lowercase characters using the str.lower method. However, the map function needs to be wrapped in a list() or join() to apply the transformation to each character.

Python3




original_string = "GeeksforGeeks"
lowercased_string = ''.join(map(str.lower, original_string))
print(lowercased_string)


Output :

geeksforgeeks

Convert String to lowercase using Swapcase() Function

Convert uppercase to lowercase in Python using the swapcase() function. In this example, code defines a string ‘GEEKSFORGEEKS’ in variable ‘s’. The `swapcase()` method is then applied to the string, converting uppercase letters to lowercase and vice versa.

Python3




s = 'GEEKSFORGEEKS'
print(s.swapcase())


Output:

geeksforgeeks

Convert String to lowercase using casefold() Function

Convert uppercase to lowercase in Python using the casefold function. In this example code converts the string ‘GEEKSFORGEEKS’ to its casefolded form, making it lowercase and suitable for case-insensitive comparisons.

Python3




s = 'GEEKSFORGEEKS'
print(s.casefold())


Output:

geeksforgeeks

Applications of String lower() method

Let’s look at some other uses of the string lower() method in Python. It can be used in other ways, depending on your creativity. We have mentioned one such use of the Python lower() method.

Comparison of Strings using lower() Method

One of the common applications of the lower() method is to check if the two strings are the same or not. In this example, the code compares two strings, `text1` and `text2`, after converting them to lowercase using the `lower()` method. If the lowercase versions of the strings are equal, it prints “Strings are same”; otherwise, it prints “Strings are not same.”

Python3




text1 = 'GEeKS foR GeeKs'
text2 = 'gEeKS fOR GeeKs'
 
# Comparison of strings using
# lower() method
if(text1.lower() == text2.lower()):
    print("Strings are same")
else:
    print("Strings are not same")


Output: 

Strings are same

We have discussed how to use the lower() method to convert a string to lowercase and also discussed some other ways to perform the same task. The techniques are explained through a program as an example for a better understanding of methods.

You can also check other string methods

Read more related content on the Python Lower Method:



Previous Article
Next Article

Similar Reads

Python String Methods | Set 1 (find, rfind, startwith, endwith, islower, isupper, lower, upper, swapcase & title)
Some of the string basics have been covered in the below articles Strings Part-1 Strings Part-2 The important string methods will be discussed in this article1. find("string", beg, end) :- This function is used to find the position of the substring within a string.It takes 3 arguments, substring , starting index( by default 0) and ending index( by
4 min read
numpy string operations | lower() function
numpy.core.defchararray.lower(arr) function is used to return an array with the elements converted to lowercase. Parameters: arr : [ array_like ] Input array which may be str or unicode. Returns : [ndarray] Output lowercased array of str or unicode, depending on input type. Code #1: # Python Program explaining # numpy.char.lower() function import n
1 min read
PyQt5 - lower() method for Labels
In PyQt5, when we create more than one label at same position they overlap each other such that the label which was made at last should be shown at top. Although, we can set the opaque level but sometimes some label have lower priority and that's why they should be at below level therefore, lower() method is used. Syntax : label.lower() Argument :
2 min read
Integrate Legendre series and set the lower bound of the integral using NumPy in Python
In this article, we will see how to integrate a Legendre series and set the lower bound of the integral in Python using NumPy. To perform Legendre integration, NumPy provides a function called legendre.legint which can be used to integrate Legendre series. Syntax: legendre.legint(c, lbnd=0, scl=1, axis=0) Parameters: c – Array of Legendre series co
2 min read
Python | Pandas Series.str.lower(), upper() and title()
Python is a great language for data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages, making importing and analyzing data much easier. Python has some inbuilt methods to convert a string into a lower, upper, or Camel case. But these methods don't work on lists and other multi-st
4 min read
Higher-Lower Game with Python
In this article, we will be looking at the way to design a game in which the user has to guess which has a higher number of followers and it displays the scores. Game Play:The name of some Instagram accounts will be displayed, you have to guess which has a higher number of followers by typing in the name of that account. Make sure you type the name
8 min read
Integrate a Chebyshev series and set the lower bound of the integral using NumPy in Python
In this article, we will see how to integrate a Chebyshev series and set the lower bound of the integral in Python using Numpy. To perform Chebyshev integration, NumPy provides a function called chebyshev.chebint which can be used to integrate Legendre series. Syntax: chebyshev.chebint(c, lbnd=0, scl=1, axis=0) Parameters: c – Array of Chebyshev se
2 min read
Difference between casefold() and lower() in Python
In this article, we will learn the differences between casefold() and lower() in Python. The string lower() is an in-built method in Python language. It converts all uppercase letters in a string into lowercase and then returns the string. Whereas casefold() method is an advanced version of lower() method, it converts the uppercase letter to lowerc
2 min read
PyQt5 QSpinBox – Showing it on lower level
In this article we will see how we can make the spin box at lower level, lower level means at it will show on the bottom if it collides with some other spin box position, by default when we create two spin box at similar position, the spin box which was created at the end will show on the top although we can change this. In order to do this we will
2 min read
PyQt5 QDial - Setting Lower Bound of it
In this article we will see how we can set the lower bound of QDial. Lower bound means the lowest value QDial can handle by default the minimum value is 0 although we can change it any time. With the lower bound we can make sure the number below the lower bound can be assigned. Setting lower bound will not affect the movement of the Qdial it will s
2 min read
PyQt5 QDial - Getting Lower Bound
In this article we will see how we can get the lower bound of QDial. Lower bound means the lowest value QDial can handle by default the minimum value is 0 although we can change it any time with the help of setMinimum method. With the lower bound we can make sure the number below the lower bound can be assigned. Setting lower bound will not affect
2 min read
Class Method vs Static Method vs Instance Method in Python
Three important types of methods in Python are class methods, static methods, and instance methods. Each serves a distinct purpose and contributes to the overall flexibility and functionality of object-oriented programming in Python. In this article, we will see the difference between class method, static method, and instance method with the help o
5 min read
String slicing in Python to check if a string can become empty by recursive deletion
Given a string “str” and another string “sub_str”. We are allowed to delete “sub_str” from “str” any number of times. It is also given that the “sub_str” appears only once at a time. The task is to find if “str” can become empty by removing “sub_str” again and again. Examples: Input : str = "GEEGEEKSKS", sub_str = "GEEKS" Output : Yes Explanation :
2 min read
String slicing in Python to Rotate a String
Given a string of size n, write functions to perform following operations on string. Left (Or anticlockwise) rotate the given string by d elements (where d <= n).Right (Or clockwise) rotate the given string by d elements (where d <= n).Examples: Input : s = "GeeksforGeeks" d = 2Output : Left Rotation : "eksforGeeksGe" Right Rotation : "ksGeek
3 min read
Python | Sorting string using order defined by another string
Given two strings (of lowercase letters), a pattern and a string. The task is to sort string according to the order defined by pattern and return the reverse of it. It may be assumed that pattern has all characters of the string and all characters in pattern appear only once. Examples: Input : pat = "asbcklfdmegnot", str = "eksge" Output : str = "g
2 min read
String Alignment in Python f-string
Text Alignment in Python is useful for printing out clean formatted output. Some times the data to be printed varies in length which makes it look messy when printed. By using String Alignment the output string can be aligned by defining the alignment as left, right or center and also defining space (width) to reserve for the string. Approach : We
2 min read
String to Int and Int to String in Python
Python defines type conversion functions to directly convert one data type to another. This article is aimed at providing the information about converting a string to int and int to string. Converting a string to an int If we want to convert a number that is represented in the string to int, we have to use the int() function. This function is used
2 min read
Pad or fill a string by a variable in Python using f-string
f-string stands for formatted string. It had come up by Python Version 3.6 and rapidly used to do easy formatting on strings. F-string is a string literal having syntax starts with f and followed by {}. That placeholder used for holding variable, that will be changed upon the variable names and their values respectively. There are already strings f
4 min read
Convert Unicode String to a Byte String in Python
Python is a versatile programming language known for its simplicity and readability. Unicode support is a crucial aspect of Python, allowing developers to handle characters from various scripts and languages. However, there are instances where you might need to convert a Unicode string to a regular string. In this article, we will explore five diff
2 min read
Python string length | len() function to find string length
The string len() function returns the length of the string. In this article, we will see how to find the length of a string using the string len() method. Example: [GFGTABS] Python string = "Geeksforgeeks" print(len(string)) [/GFGTABS]Output13String len() Syntaxlen(string) ParameterString: string of which you want to find the length. Retu
5 min read
Python String Formatting - How to format String?
String formatting allows you to create dynamic strings by combining variables and values. In this article, we will discuss about 5 ways to format a string. You will learn different methods of string formatting with examples for better understanding. Let's look at them now! How to Format Strings in PythonThere are five different ways to perform stri
10 min read
Python String casefold() Method
Python String casefold() method is used to convert string to lowercase. It is similar to the Python lower() string method, but the case removes all the case distinctions present in a string. Python String casefold() Method Syntax Syntax: string.casefold() Parameters: The casefold() method doesn't take any parameters. Return value: Returns the case
1 min read
Python String isspace() Method
Python String isspace() method returns “True” if all characters in the string are whitespace characters, Otherwise, It returns “False”. This function is used to check if the argument contains all whitespace characters, such as: ‘ ‘ – Space‘\t’ – Horizontal tab‘\n’ – Newline‘\v’ – Vertical tab‘\f’ – Feed‘\r’ – Carriage returnPython String isspace()
2 min read
Python String isalpha() Method
Python String isalpha() method is used to check whether all characters in the String are an alphabet. Python String isalpha() Method SyntaxSyntax: string.isalpha() Parameters: isalpha() does not take any parameters Returns: True: If all characters in the string are alphabet.False: If the string contains 1 or more non-alphabets.Errors and Exceptions
4 min read
Python String isprintable() Method
Python String isprintable() is a built-in method used for string handling. The isprintable() method returns "True" if all characters in the string are printable or the string is empty, Otherwise, It returns "False". This function is used to check if the argument contains any printable characters such as: Digits ( 0123456789 )Uppercase letters ( ABC
3 min read
Python String isdigit() Method
Python String isdigit() method returns “True” if all characters in the string are digits, Otherwise, It returns “False”. Python String isdigit() Method Syntax Syntax: string.isdigit() Parameters: isdigit() does not take any parameters Returns: True - If all characters in the string are digits.False - If the string contains 1 or more non-digits. Tim
3 min read
Python String isnumeric() Method
The isnumeric() method is a built-in method in Python that belongs to the string class. It is used to determine whether the string consists of numeric characters or not. It returns a Boolean value. If all characters in the string are numeric and it is not empty, it returns “True” If all characters in the string are numeric characters, otherwise ret
3 min read
Python String splitlines() Method
Python String splitlines() method is used to split the lines at line boundaries. The function returns a list of lines in the string, including the line break(optional). Syntax: string.splitlines([keepends]) Parameters: keepends (optional): When set to True line breaks are included in the resulting list. This can be a number, specifying the position
2 min read
Python String center() Method
Python String center() method creates and returns a new string that is padded with the specified character. Syntax: string.center(length[, fillchar]) Parameters: length: length of the string after padding with the characters.fillchar: (optional) characters which need to be padded. If it's not provided, space is taken as the default argument. Return
2 min read
Python String istitle() Method
Python String istitle() Method is a built-in string function that returns True if all the words in the string are title cased, otherwise returns False. Python String istitle() Method Syntax Syntax: string.istitle() Returns: True if the string is a title-cased string otherwise returns False. Python String istitle() Method Example C/C++ Code string =
2 min read
Practice Tags :