Python String islower() Method

13-02-23 Ahmed Obaid 930 0

​The islower() function checks if characters in a string are lowercase. If characters in the string are lowercase it will return the boolean value True. Otherwise, it will return the boolean value False.


The way it is written is like this:


string.islower ()

Parameters: The islower() function does not take any parameters.

return value:

True: if characters in the string are lowercase.

False: If the string contains one or more non-lowercase characters.

Errors and exceptions:

If a parameter is passed to the islower() function, an error occurs


Example:


# Define a variable made up of lowercase letters
string = "learn python with ahmed obaid"
#islower function call
result = string. islower() # returns True
# Print the result
print(result)
# Define a variable composed of lowercase and uppercase letters
string = "Learn Python with Ahmed Obaid"
#islower function call
result = string. islower() # returns False
# Print the result
print(result)
# Define a variable composed of uppercase letters
string = "LEARN PYTHON WITH AHMED OBAID"
#islower function call
result = string. islower() #undefined returns False
 # Print the result
 print(result)

 The output will be:


 True
 False
 False

 The islower() function always returns the boolean value True. If the string contains lowercase letters, numbers and symbols.

 Example:


 # Define a variable consisting of lowercase letters, numbers and symbols
 string = "@Ahmed Obaid 2023"
 #islower function call
 result = string. islower() # returns True
 # Print the result
 print(result)

 The output will be:


 True

 The islower() function always returns a boolean False if the string contains only symbols and numbers. Without lowercase letters.

 Example:


 # Define a variable composed of numbers and symbols
 string = "100$"
 #islower function call
 result = string. islower() # returns False
 # Print the result
 print(result)

 The output will be:


 False

 External sources:

 Built-in functions - official Python documentation

 If you have any questions or concerns, leave them in the comments



Tags


Python python data types Python String string methods python String comparison functions in Python Python String islower Method

Share page