Python Lowercase Method with Examples

Posted in /  

Python Lowercase Method with Examples

Vinay Khatri
Last updated on July 21, 2024

    In Python, a string object has many built-in methods which can also help in manipulating the case of the string. The string .lower() method can convert all the uppercase characters of the string into a lower case and return the value. This method comes very useful when we want to check if two strings are the same despite their's casing.

    Python string .lower() method

    The . lower() Method can only apply on the string variables or objects, and it returns a copy of the string characters all in lower case.




    >>> title = "TechGeekBuZZ"
    >>> t = title.lower()
    >>> print(t)



    How to Check if two strings are the same?

    The == operator return True if both the string has the equal value and similar casing. But if both the strings have the same value and different casing it returns False. This could be a problem when we do not want to consider casing. So to solve this kind of problem we can use the string .lower() method.


    a = ""
    b = ""
    if a.lower() == b.lower():
        print("Both the urls are same")
        print("Both the urls are different")


    Both the urls are same

    String .islower() method

    The islower() is a string method is used to check if all the characters of the string are in lowercase or not.  This method returns True if all the characters in the string are in lower case. If the string contains even a single uppercase character, then this method returns False.


    >>> str1 = "Techgeekbuzz"
    >>> str1.islower()
    >>> str2 ="techgeekbuzz"
    >>> str2.islower()

    Python string upper() and isupper() methods

    • The upper() method works opposite of lower() method, it converts all the string character to uppercase character.
    • The isupper() method is used to check if all the characters in the string are in uppercase or not.


    a = ""
    b= a.upper()




    • To convert all the characters of a string into lowercase, we use the .lower() method.
    • The islower() method check the lowercase character in a string.
    • The upper() method converts all the string characters into uppercase.
    • The lower() and upper() can be used to check if both the string are same despite of the characters casing.

    People are also reading:

    Leave a Comment on this Post