In this tutorial, we’ll learn what Python string islower() method is and how to properly use it. We’ll go through multiple Python code examples to understand how islower() method works in Python.
Introduction: Python String islower() Method
This method will return True if a string contains only lowercase alphabets and will return False is atleast one alphabet is uppercase.
Syntax of islower() Method
string.islower()
- Python string islower() method does not take any arguments.
- This method returns True if a string has only lowercase alphabets and will return False if atleast one alphabet is in uppercase format.
Example 1: islower() Method Applied on a Python String
val='this is python programming' print(val.islower())
Output
True
Python string islower method return True as all the alphabets are in lowercase format in the above string.
See below examples in which string contains uppercase alphabets as well.
print( 'this is Python Programming'.islower() ) print( 'Python'.islower() ) print( 'python Programs'.islower() )
Output
False False False
Example 2: islower() used in If Else Condition inside For Loop
listStr=['python','python Language','programming in python','python3'] for val in listStr: if val.islower()==True: print(val+' - islower method returns True') else: print(val+' - islower method returns False')
Output
python - islower method returns True python Language - islower method returns False programming in python - islower method returns True python3 - islower method returns True
Example 3: islower() Method Return Value
val= 'python3 programming language in 2022' returnedValue= val.islower() print( returnedValue )
Output
True
Python string islower method return True as the specified string consists of only lowercase alphabets.
Conclusion
To conclude this tutorial, hope you now have a detailed practical knowledge of how to properly use Python string islower method. I’ll be looking forward to have your valuable feedback on this post. Thank you for reading it.