Methods and Functions

Python String islower()

Python islower() built-in function is developed for handling specific string operations. The string method in Python islower() determines if all of the string’s case-based characters (letters) are lowercase. The Python islower() function is used to determine whether a string contains lowercase letters. Let us dig deep and understand more about Python’s islower() string class function along with examples.

Python islower() function

Definition

  • The Python islower() function returns True if all of the alphabets in the string are lowercase and if the string contains at least one capital alphabet, it returns False.
  • If all the characters in a string are lowercase, the Python islower() string function returns True; otherwise, it returns False.

islower() Syntax

The islower() method is a built-in string handling function. Python islower() follows the below syntax method:

                    

string.islower()

islower() Parameters

The islower() function does not accept any parameters. If any parameters are passed, an error will be generated.

Return value of islower()

Python’s string islower() function is responsible for returning a Boolean value:

  • True – if all the alphabets in the string are of lowercase
  • False – if the string contains at least one alphabet which is in uppercase state

Note – The islower() function always returns False if the given string contains only symbols or numbers. If there is at least one alphabet along with symbols and numbers, then the function checks the condition and returns True or False accordingly.

Example 1: Return value from islower()

Example

                    

# Python program to illustrate islower()
# contains all lowercase characters
txt = 'what a lovely day'
print(txt.islower())

# contains uppercase as well as lowercase characters
txt = 'What a Lovely Day'
print(txt.islower())

# contains numbers and lowercase characters
txt = '1 am g00d'
print(txt.islower())

# contains only symbols and numbers
txt = '138$^#'
print(txt.islower())

# empty string
txt = ' '
print(txt.islower())

Output

                    

True
False
True
False
False

Example 2: How to use islower() in a program?

Example

                    

# Python program to illustrate islower() in real-life applications
txt = 'this is a nice place to camp'
if txt.islower() == True:
    print('Does not contain any uppercase letters')
else:
    print('Contains uppercase letters')

txt = 'I have a pet dog'
if txt.islower() == True:
    print('Does not contain any uppercase letters')
else:
    print('Contains uppercase letters')

Output

                    

Does not contain any uppercase letters
Contains uppercase letters

Errors and Exceptions while using islower()

  • Python islower() returns “True” for whitespaces, but returns “False” if the string contains only whitespace.
  • As the islower() function does not accept any arguments, it returns an error if a parameter is passed.
  • If the string contains digits and symbols along with characters, then it returns “True”, but if the string contains only numbers and digits, it returns “False”.

Frequently Asked Questions

Q1. What does islower() do in Python?

Python islower() built-in function is developed for handling specific string operations. The string method in Python islower() determines if all of the string’s case-based characters (letters) are lowercase. If all the characters in a string are lowercase, the Python islower() string function returns True; otherwise, it returns False.

Q2. Explain islower in Python along with examples?

The Python islower() function returns True if all of the alphabets in the string are lowercase and if the string contains at least one capital alphabet, it returns False. Python islower() follows the below syntax method:

                    

string.islower()

Python’s string islower() function is responsible for returning a Boolean value:

  • True – if all the alphabets in the string are of lowercase
  • False – if the string contains at least one alphabet which is in uppercase state

Example

                    

# Python program to illustrate islower()
# contains all lowercase characters
txt = 'hello everyone'
print(txt.islower())

# contains uppercase as well as lowercase characters
txt = 'Good Morning Everyone'
print(txt.islower())

# contains numbers and lowercase characters
txt = '12sdfjb543'
print(txt.islower())

# contains only symbols and numbers
txt = '0315&*!$279'
print(txt.islower())

# empty string
txt = ' '
print(txt.islower())

Output

                    

True
False
True
False
False

Q3. How do you capitalize all letters in Python?

When working with a string in Python, you may want to convert the string to uppercase or check if the string is already in uppercase. This is where the Python upper() method comes into play. The upper() function in Python changes all the lowercase characters in a string to uppercase and returns the resulting string.

Syntax:

                    

string.upper()

Example

                    

# Python program to illustrate upper()
# string with all lowercase letters
txt = 'hello everyone'
print(txt.upper())

# string with numbers
txt = 'Hello Everyone. H0w a3e you a11'
print(txt.upper())

Output

                    

HELLO EVERYONE
HELLO EVERYONE. H0W A3E YOU A11

Share with friends

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

Your email address will not be published. Required fields are marked *

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

No thanks.