Python String islower() Method



The python string islower() method is used to check whether the string contains lowercases. This method returns true if all the cased characters in the input string are lowercases and there is atleast one cased character. Otherwise, it returns false.

Let us look into this method with more details in the following section.

Syntax

Following is the syntax for the python string islower() method −

str.islower()

Parameters

The python string islower() method doesnot contain any parameters.

Return Value

The python string islower() method returns true if all the cased characters in the string are lowercases and there is at least one cased character and false otherwise.

Example

The following is an example of the python string islower() method. In this program, a string "Hello! Welcome to Tutorialspoint!" is created and the islower() method is invoked to check whether all the characters present in the created string are in lowercase. The resultant output is obtained and printed using the print() method.

#!/usr/bin/python
str = "Hello! Welcome to Tutorialspoint!"; 
result=str.islower()
print("Are all the cased characters in the string lowercases?", result)

On executing the above program, the following output is generated -

Are all the cased characters in the string lowercases? False

Example

If there are empty spaces in the created string "Hello! Welcome to Tutorialspoint" in between the cased characters, the python string islower() method only checks the cased characters and returns the result accordingly.

#!/usr/bin/python
str = "welcome to tutorialspoint"; 
result=str.islower()
print("Are all the cased characters in the string lowercases?", result)

The following is the output obtained by executing the above program -

Are all the cased characters of the string lowercases? True

Example

No matter what other characters the created string "Welcome_to_Tutorialspoint!" contains, if the cased characters are in lowercase, then the islower() method returns true.

#!/usr/bin/python
str = "welcome_to_tutorialspoint!"; 
result=str.islower()
print("Are all the cased characters in the string lowercases?", result)

The following output is obtained by executing the above program -

Are all the cased characters of the string lowercases? True

Example

No matter what other characters the created string "Welcome123" contains, if the cased characters are in lowercase, then the islower() method returns true.

#!/usr/bin/python
str = "welcome123"; 
result=str.islower()
print("Are all the cased characters in the string lowercases?", result)

The above program, on executing, displays the following output -

Are all the cased characters of the string lowercases? True

Example

If the created string is empty or contains only empty spaces, the islower() method returns false.

#!/usr/bin/python
str = ""; 
result=str.islower()
print("Are all the cased characters in the string lowercases?", result)

The output of the above program is displayed as follows -

Are all the cased characters of the string lowercases? False
python_strings.htm
Advertisements