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()
Code language: CSS (css)
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 = '[email protected]'
is_lowercase = email.islower()
print(is_lowercase)
Code language: PHP (php)
Output:
True
Code language: PHP (php)
However, the following example returns False because the first character of the string is uppercase:
email = '[email protected]'
is_lowercase = email.islower()
print(is_lowercase)
Code language: PHP (php)
Output:
False
Code language: PHP (php)
The following example return False
because the string has no cased characters:
number_str = '123'
is_lowercase = number_str.islower()
print(is_lowercase)
Code language: PHP (php)
Output:
False
Code language: PHP (php)
Summary #
- Use the Python string
islower()
method to determine if all cased characters of a string are lowercase.