Python String islower()

Python String islower() method

Python String islower() method is used to check if all cased characters in the string are lower case.

Consider that given string is in x.

x = "hello world"

Then the return value of x.islower() is

False

In this tutorial, you will learn the syntax and usage of String islower() method in Python language.

Syntax of islower() method

The syntax of String islower() method in Python is given below.

str.islower()

Parameters

The islower() method takes no parameters.

Return value

islower() method returns a boolean value of True if all cased characters in the string are lower case characters, and also there is at least one cased character in the string, otherwise False.

Examples

1. Checking if given string is lower case in Python

In this example, we take a string value in variable my_string. We have to check if all cased characters in the string are lower case.

Call islower() method on the string my_string and use the returned value as a condition in Python if else statement as shown in the following program.

Since all cased characters in the string are lower case, islower() method returns True, and the if-block executes.

Python Program

my_string = "hello world"

if my_string.islower():
    print('Given string is LOWER CASE.')
else:
    print('Given string is NOT LOWER CASE.')
Run Code Copy

Output

Given string is LOWER CASE.

2. Checking if given string (with some upper case characters) is lower case in Python

In the following program, we take a string value in variable my_string such that some of the characters in the string are upper case.

Since, not all cased characters in the string are lower case, islower() method returns False, and the else-block executes.

Python Program

my_string = "Hello World"

if my_string.islower():
    print('Given string is LOWER CASE.')
else:
    print('Given string is NOT LOWER CASE.')
Run Code Copy

Output

Given string is NOT LOWER CASE.

3. Checking if given string (with no cased characters) is lower case in Python

In the following program, we take a string value in variable my_string such that there is no cased character in the string.

Since, there is no at least one cased character in the string, islower() method returns False, and the else-block executes.

Python Program

my_string = ".@ -"

if my_string.islower():
    print('Given string is LOWER CASE.')
else:
    print('Given string is NOT LOWER CASE.')
Run Code Copy

Output

Given string is NOT LOWER CASE.

Summary

In this tutorial of Python String Methods, we learned about String islower() method, its syntax, and examples.

Code copied to clipboard successfully 👍