Python String islower() Method
Last Updated :
11 Nov, 2024
Improve
The islower() method in Python checks if all characters in a string are lowercase. It returns True if all alphabetic characters are lowercase, otherwise, it returns False, if there is at least one uppercase letter.
Let's look at a quick example of using the islower() method.
s = "hello"
res = s.islower()
print(res)
Output
True
Explanation: The string s contains only lowercase alphabetic characters, so islower() returns True.
Table of Content
Syntax of islower()
s.islower()
Parameter:
- This method doesn't take any parameter.
Return Value:
- The method return True if all alphabetic characters in the string are lowercase, otherwise False.
Example of islower()
Let’s look at a few examples of islower() method.
s1 = "hello"
res1 = s1.islower()
print(res1)
s2 = "Hello"
res2 = s2.islower()
print(res2)
s3 = "hello123"
res3 = s3.islower()
print(res3)
s4 = ""
res4 = s4.islower()
print(res4)
s5 = "123@"
res5 = s5.islower()
print(res5)
Output
True False True False False
Explanation:
- s1 is "hello": contains only lowercase letters, so islower() returns True.
- s2 is "Hello": has an uppercase 'H', so islower() returns False.
- s3 is "hello123": all alphabetic characters are lowercase, so islower() returns True.
- s4 is "": an empty string returns False by default.
- s5 is "123@": contains no alphabetic characters, so islower() returns False. At least one lowercase letter is needed for True.
Related Articles:
- Python String isupper() Method
- Python String isalpha() Method
- Python String isdigit() Method
- Python String isalnum() Method