Python String islower()
Summary: in this tutorial, you’ll learn how to use the Python string islower()
method to check if all cases characters are lowercase.
Introduction to the Python String islower() method
The following shows the syntax of the string islower()
method:
str.islower()
The string islower()
method returns True
if all cased characters are lowercase. Otherwise, it returns False
.
If the string doesn’t contain any cased characters, the islower()
method also returns False
.
In Python, cased characters are the ones with general category property being one of:
- Lu (letter, uppercase)
- Ll (letter, lowercase)
- Lt (letter, titlecase)
Note that to return a copy of the string with all characters converted to lowercase, you use the string lower()
method.
Python String islower() method examples
Let’s take some examples of using the string islower()
method.
The following example uses the islower()
to check if all characters of an email are lowercase:
email = 'hello@example.com'
is_lowercase = email.islower()
print(is_lowercase)
Output:
True
However, the following example returns False because the first character of the string is uppercase:
email = 'Admin@example.com'
is_lowercase = email.islower()
print(is_lowercase)
Output:
False
The following example return False
because the string has no cased characters:
number_str = '123'
is_lowercase = number_str.islower()
print(is_lowercase)
Output:
False
Summary
- Use the Python string
islower()
method to determine if all cased characters of a string are lowercase.