Python String islower()

Filed Under: Python

Python string islower()
Python String islower() returns True if all cased characters in the string are lowercase and there is at least one cased character, otherwise it returns False.

Python String islower()

Cased characters are those with general Unicode category property being one of “Lu” (Letter, uppercase), “Ll” (Letter, lowercase), or “Lt” (Letter, titlecase).

Let’s look at some examples of Python string islower() function.


s = 'abc'
print(s.islower())

Output: True because all the string cased characters are in lowercase.


s = 'Abc'
print(s.islower())

Output: False because one of the cased character is in Uppercase.


s = '123'
print(s.islower())

Output: False because there are no cased characters in the string.


s = 'a123'
print(s.islower())

Output: True because all the string cased characters are in lowercase.


s = 'åçĕń'
print(s.islower())

Output: True because all the string cased characters are in lowercase.

Print all lowercase Unicode characters

We can use unicodedata module to check if a character is in lowercase or not. Here is the code snippet to print all the lowercase Unicode characters.


import unicodedata

count = 0
for codepoint in range(2 ** 16):
    ch = chr(codepoint)
    if ch.islower():
        print(u'{:04x}: {} ({})'.format(codepoint, ch, unicodedata.name(ch, 'UNNAMED')))
        count = count + 1
print(f'Total Number of Lowercase Unicode Characters = {count}')

Output:


0061: a (LATIN SMALL LETTER A)
0062: b (LATIN SMALL LETTER B)
...
ff58: x (FULLWIDTH LATIN SMALL LETTER X)
ff59: y (FULLWIDTH LATIN SMALL LETTER Y)
ff5a: z (FULLWIDTH LATIN SMALL LETTER Z)
Total Number of Lowercase Unicode Characters = 1617
If you are not familiar with f-prefixed string formatting, please read f-strings in Python.
You can checkout more Python examples from our GitHub Repository.

Reference: Official Documentation

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages