Python String islower() method is a built-in function that returns True
if all the characters in the string are lowercase. If the string contains at least one uppercase character, the method returns False
.
Syntax
The syntax of islower()
method is:
string.islower()
Parameter
The islower()
method doesn’t take any parameters.
Return Value
The islower()
method returns:
True
if all alphabets in a string are lowercase alphabets.False
if the string contains one or more uppercase alphabets.
Example 1: Demonstrating the working of islower() method
text1="Itsmycode"
text2="itsmycode"
print("Is Itsmycode all lowercase:",text1.islower())
print("Is itsmycode all lowercase:",text2.islower())
Output
Is Itsmycode all lowercase: False
Is itsmycode all lowercase: True
Example 2: Practical use case of islower() in a program
The following program will determine if the given sentence consists of all lowercase characters.
text1 = "Python is fun"
text2 = "python tutorials"
if(text1.islower()==True):
print("The text contains all lowercase characters")
else:
print("The text contains at least one uppercase characters")
if(text2.islower()==True):
print("The text contains all lowercase characters")
else:
print("The text contains at least one uppercase characters")
Output
The text contains at least one uppercase characters
The text contains all lowercase characters