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 lowercasestring = 'all lowercase';print(string.islower())# False - because N is uppercasestring = 'Non lowercase';print(string.islower())# False - because no alphabetical character presentstring = '10';print(string.islower())# True - because one alphabetical character present and that character is in lower casestring = '12b';print(string.islower())# False - because one alphabetical character present and that character is not lower casestring = '12B';print(string.islower())
In the code above, we call the islower method:
-
For the
all lowercasestring, theislowermethod will returnTruebecause all the characters of the string are lowercase letters. -
For the
Non lowercasestring, theislowermethod will returnFalsebecause the string contains one uppercase letter (N). -
For the
10string, theislowermethod will returnFalsebecause the string contains no alphabetical letter. -
For the
12bstring, theislowermethod will returnTruebecause the string has one alphabetical character, and that character is in lowercase. -
For the
12Bstring, theislowermethod will returnFalsebecause the string has one uppercase character (B).