| by Arround The Web | No comments

Python String islower() Method

Python provides a wide range of methods and modules that resolve simple to complex tasks easily and within fewer lines of code. Python also provides various methods for string manipulation that perform operations on strings. One such method is the “string.islower()” method which checks whether the passed string consists of lowercase letters.

This blog provides a detailed guide on Python’s “string.islower()” method via the following contents:

What is the Python “string.islower()” Method?

In Python, the “string.islower()” method is utilized to retrieve the Boolean value “True” if all the letters/characters in the string are lowercase and “False” if at least one letter in the string is uppercase.

Note: The “string.islower()” method checks only alphabetic characters and does not operate numbers, symbols, or spaces.

Syntax

string.islower()

 
Parameters

The “string.islower()” method does not accept/take any parameter value.

Return Value

The “string.islower()” method is used to retrieve the Boolean value “True” when the string contains all the lowercase alphabets and returns “False” otherwise.

Example 1: Applying the “string.islower()” Method to Check the Lowercase Letters/Characters in the Specified String

The “string.islower()” method is used in the below code to check whether the characters/letters in the specified string contain all the lowercase letters or not:

value1 = "PYTHON"
print('Value 1: ', value1)
print('Value 1 Includes All Lowercase Letters: ', value1.islower())

value2 = "python"
print('\nValue 2: ', value2)
print('Value 2 Includes All Lowercase Letters: ', value2.islower())

value3 = "Python"
print('\nValue 3: ', value3)
print('Value 3 Includes All Lowercase Letters: ', value3.islower())

 
In the above code:

    • The multiple string values containing uppercase, lowercase, and mixed (uppercase and lowercase) letters/characters, respectively are initialized in the code.
    • The “string.islower()” method is then used to retrieve the value “True” if all the lowercase letters are found in the specified string and retrieve “False” when there is at least one uppercase letter in the specified string.

Output


As seen, the outcome is returned accordingly.

Example 2: Applying the “string.islower()” Method to Check the Lowercase Letters/Characters in the User Input String

The below code is used to check whether the user-input string contains all the lowercase letters or not:

value1 = input()
print(value1.islower())

 
In the above code:

    • The “input()” function is used to get the input from the user and store it in the variable named “value1”.
    • The associated “islower()” method checks whether the user input string contains all the lowercase letters.

Output


Here, it can be implied that the “True” and “False” Boolean values are returned appropriately.

Conclusion

The Python “string.islower()” method checks whether the string contains all the lowercase letters or not by retrieving the corresponding Boolean values “True” and “False”. This method retrieves “True” when all characters in the specified string are lowercase and “False” when there is at least one uppercase character in the string. This post presented a detailed guide on Python’s “string.islower()” method using numerous examples.

Share Button

Source: linuxhint.com

Leave a Reply