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

Python String islower() Function

Python String islower() function checks if all the characters in a string are lowercase then return True else False.

Key Points :

  • Return Type: Boolean i.e. True or False
  • Parametric Values: No Parameters required
  • It is not space-sensitive but case sensitive
  • Empty String also returns False.

String islower() Syntax

str_name.islower()

str_name here refers to the input string. And, islower() is inbuilt string function in python.

str_name = "welcome"
print(str_name.islower())   # True

String islower() Examples

Different cases are given below.

Case 1: Every character in a string is lowercase also contains whitespaces/numbers/special characters

str_name = "welcome python user"
print(str_name.islower())   # True
 
str_name = "welcome 2019"
print(str_name.islower())   # True
 
str_name = "welcome @ 2020"
print(str_name.islower())   # True

Case 2: Every character in a string is uppercase, also contains whitespaces/numbers/special characters

str_name = "WELCOME PYTHON USER"
print(str_name.islower())   # False
 
str_name = "WELCOME 2019"
print(str_name.islower())   # False

str_name = "WELCOME @ 2020"
print(str_name.islower())   # False

Case 3: String contains only numbers or special characters

str_name = "2020"
print(str_name.islower())   # False
 
str_name = "@$&"
print(str_name.islower())   # False

Case 4: Only the first character of every word is uppercase, also contains whitespaces/numbers/special characters

str_name = "Welcome"
print(str_name.islower())   # False
 
str_name = "Welcome Python User"
print(str_name.islower())   # False
 
str_name = "Welcome 2019"
print(str_name.islower())   # False
 
str_name = "Welcome @ 2020"
print(str_name.islower())   # False

Case 5: String is Empty

str_name = ' '
print(str_name.islower())   # False

Program to Print List of All Possible Lowercase Characters in Python

The Unicode module can be used to check the lowercase characters. The program is to print all lowercase Unicode characters.

import unicodedata

total_count = 0
for i in range(2 ** 16):
    charac = chr(i)
    if charac.islower():
        print(u'{:04x}: {} ({})'.format(i, charac, unicodedata.name(charac, 'UNNAMED')))
        total_count = total_count + 1
print("Total Number of Lowercase Unicode Characters = ",total_count)
Output All Lowercase Unicode Characters
Output All Lowercase Unicode Characters

It is just a glance of output as the actual output is lengthy. There are 1402 Lowercase characters in Unicode.


References