Python String islower() Method with Examples

In the previous article, we have discussed Python String zfill() Method with Examples
islower() Method in Python:

If all of the characters are in lower case, the islower() method returns True; otherwise, it returns False.

Only alphabet characters are checked, not numbers, symbols, or spaces.

Syntax:

string.islower()

Parameters: This function has no parameters.

Return Value:

The islower() method gives:

  • True if all of the alphabets in the string are lowercase.
  • If the string contains at least one uppercase alphabet, this function returns False.

Examples:

Example1:

Input:

Given string = 'welcome to python-programs'
Given string = '1234 Hello ALL @'
Given string = 'good morning btechgeeks 12345 @#!'

Output:

The given string =  welcome to python-programs
Checking if the given string has all lowercase characters or not =  True
The given string =  1234 Hello ALL @
Checking if the given string has all lowercase characters or not =  False
The given string =  good morning btechgeeks 12345 @#!
Checking if the given string has all lowercase characters or not =  True

Example2:

Input:

Given string = 'hello this is btech_geeks'
Given string = 'ThIs IS a PYThon learning PLATform'
Given string = '#### hello everyone ##%%$12346'

Output:

The given string =  hello this is btech_geeks
Checking if the given string has all lowercase characters or not =  True
The given string =  ThIs IS a PYThon learning PLATform
Checking if the given string has all lowercase characters or not =  False
The given string =  #### hello everyone ##%%$12346
Checking if the given string has all lowercase characters or not =  True

String islower() Method Examples in Python

Method #1: Using Built-in Functions (Static Input)

Approach:

  • Give the string as static input and store it in a variable.
  • Apply islower() function to the given string in which if all of the characters are in lower case, the islower() method returns True; otherwise, it returns False.
  • Store it in another variable.
  • Print the above-given String.
  • Print the result after checking if the given string has all lowercase characters or not.
  • Similarly, do the same for other strings and print the result.
  • The Exit of Program.

Below is the implementation:

# Give the string as static input and store it in a variable.
gvn_strng1 = 'welcome to python-programs'
# Apply islower() function to the given string in which if all of the characters
# are in lower case, the islower() method returns True; otherwise, it returns False.
# Store it in another variable.
rslt_1 = gvn_strng1.islower()
# Print the above-given String.
print("The given string = ", gvn_strng1)
# Print the result after checking if the given string has all lowercase
# characters or not.
print("Checking if the given string has all lowercase characters or not = ", rslt_1)
# Similarly, do the same for other strings and print the result.
gvn_strng2 = '1234 Hello ALL @'
rslt_2 = gvn_strng2.islower()
print("The given string = ", gvn_strng2)
print("Checking if the given string has all lowercase characters or not = ", rslt_2)

gvn_strng3 = 'good morning btechgeeks 12345 @#!'
rslt_3 = gvn_strng3.islower()
print("The given string = ", gvn_strng3)
print("Checking if the given string has all lowercase characters or not = ", rslt_3)

Output:

The given string =  welcome to python-programs
Checking if the given string has all lowercase characters or not =  True
The given string =  1234 Hello ALL @
Checking if the given string has all lowercase characters or not =  False
The given string =  good morning btechgeeks 12345 @#!
Checking if the given string has all lowercase characters or not =  True

Method #2: Using Built-in Functions (User Input)

Approach:

  • Give the string as user input using the input() function and store it in a variable.
  • Apply islower() function to the given string in which if all of the characters are in lower case, the islower() method returns True; otherwise, it returns False.
  • Store it in another variable.
  • Print the above-given String.
  • Print the result after checking if the given string has all lowercase characters or not.
  • Similarly, do the same for other strings and print the result.
  • The Exit of Program.

Below is the implementation:

# Give the string as user input using the input() function and store it in a variable.
gvn_strng1 = input("Enter some Random String = ")
# Apply islower() function to the given string in which if all of the characters
# are in lower case, the islower() method returns True; otherwise, it returns False.
# Store it in another variable.
rslt_1 = gvn_strng1.islower()
# Print the above-given String.
print("The given string = ", gvn_strng1)
# Print the result after checking if the given string has all lowercase
# characters or not.
print("Checking if the given string has all lowercase characters or not = ", rslt_1)
# Similarly, do the same for other strings and print the result.
gvn_strng2 = input("Enter some Random String = ")
rslt_2 = gvn_strng2.islower()
print("The given string = ", gvn_strng2)
print("Checking if the given string has all lowercase characters or not = ", rslt_2)

gvn_strng3 = input("Enter some Random String = ")
rslt_3 = gvn_strng3.islower()
print("The given string = ", gvn_strng3)
print("Checking if the given string has all lowercase characters or not = ", rslt_3)

Output:

Enter some Random String = hello btechgeeks
The given string = hello btechgeeks
Checking if the given string has all lowercase characters or not = True
Enter some Random String = ThIS IS a pytHON learning PLATform
The given string = ThIS IS a pytHON learning PLATform
Checking if the given string has all lowercase characters or not = False
Enter some Random String = ###% hello everyone #$*
The given string = ###% hello everyone #$*
Checking if the given string has all lowercase characters or not = True

Go through our tutorial and learn about various Python String Method Examples and learn how to apply the knowledge while dealing with strings.