Python String islower() Method

Python String Islower() Method

This is a tutorial of the Python String islower() method. Learn to check if all of the alphabets in a given string are lowercase or not with examples.

Python String islower()

The str.islower() method returns True if the given string contains all of the alphabets in lowercase (a-z) and even if the string contains at least one alphabet in uppercase, it returns False.

Syntax

Given below is the syntax of the str.islower() method.

islower() Parameters

This method does not take any arguments as it only checks the given string on which it is applied, so no additional data is required in the form of arguments.

islower() Return Value

It returns the boolean value True or False according to the following logic.

  • Returns True if the given string contains all of the characters in lowercase.
  • Returns False if the given string contains atleast one of the characters in uppercase.

Examples

Given below are the two examples demonstrating the usage of the Python String islower() method.

Example 1. Checking a given String is lowercase using str.islower() method

In this example, we’re applying the method islower() on several different strings to check the result, for what strings it returns True and for what it returns False.

#lowercase String
name = "gurmeet singh"
print(name.islower())

#uppercase String
name = "GURMEET SINGH"
print(name.islower())

#Mixed String
name = "Gurmeet Singh"
print(name.islower())

#Alphanumeric String
name = "Hello12345"
print(name.islower())

#lowercase with numbers and symbols
name = "[email protected]#$%^"
print(name.islower())

Output.

True
False
False
False
True

Example 2. Using the Python String islower() method with if-else statement

In the following example, we’ve directly used the str.islower() method as the condition for the if-else statement to print a string accordingly after checking if the given string is in lowercase or not.

#Using str.islower() with if-else statement

#Mixed String
name = "HelloWorld12345"

if name.islower():
    print("name is in lowercase")
else:
    print("name is not in lowercase.")
    
#lowercase String
name = "helloworld12345"

if name.islower():
    print("name is in lowercase")
else:
    print("name is not in lowercase.")

Output.

name is not in lowercase.
name is in lowercase

I hope you found this guide useful. If so, do share it with others who are willing to learn Python and other programming languages. If you have any questions related to this article, feel free to ask us in the comments section.

And do not forget to subscribe to WTMatter!

Subscribe To WTMatter!

Receive updates of our latest articles via email. Enter your email address below to get started.

Leave a Reply

Your email address will not be published. Required fields are marked *