my_str.islower()
Returns True if all chars in a string are in lower case, otherwise returns False
my_str='_abc45'
print(my_str.islower()) # Output is True
my_str='ab#cd'
print(my_str.islower()) # Output is True
my_str='A_abc1234'
print(my_str.islower()) # Output is False
my_str='pq?rs'
print(my_str.islower()) # Output is True
my_str='pq rs'
print(my_str.islower()) # Output is True
my_str='12ab'
print(my_str.islower()) # Output is True
islower() ignores numbers and special characters, focusing only on alphabetic characters:
my_str = 'hello_123!'
print(my_str.islower())
True
We can use islower() to validate user input that must be in lowercase:
user_input = 'securepassword'
if user_input.islower():
print("Valid input.")
Valid input.
islower() returns False if the string contains uppercase letters:
text = 'Hello world'
print(text.islower())
False
For an empty string, islower() returns False because there are no lowercase characters to check:
empty_str = ''
print(empty_str.islower())
False
islower() works with non-ASCII characters:
text = 'maƱana'
print(text.islower())
True
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.