What is string.islower in Python?

The islower method will return True if all the alphabetical characters present in the string are in lowercase. If any character of the string is in uppercase or no alphabetical character is present in the string, then False is returned.

Syntax

string.islower()

Return value

True:

  • If all the characters of the string are in lowercase.

False in any one of the below cases:

  • If any character of the string is in uppercase.

  • If no alphabetical character is present in the string.

Example

# True - because all characters are lowercase
string = 'all lowercase';
print(string.islower())
# False - because N is uppercase
string = 'Non lowercase';
print(string.islower())
# False - because no alphabetical character present
string = '10';
print(string.islower())
# True - because one alphabetical character present and that character is in lower case
string = '12b';
print(string.islower())
# False - because one alphabetical character present and that character is not lower case
string = '12B';
print(string.islower())

In the code above, we call the islower method:

  • For the all lowercase string, the islower method will return True because all the characters of the string are lowercase letters.

  • For the Non lowercase string, the islower method will return False because the string contains one uppercase letter (N).

  • For the 10 string, the islower method will return False because the string contains no alphabetical letter.

  • For the 12b string, the islower method will return True because the string has one alphabetical character, and that character is in lowercase.

  • For the 12B string, the islower method will return False because the string has one uppercase character (B).

Free Resources