• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / islower Python – Check if All Letters in String Are Lowercase

islower Python – Check if All Letters in String Are Lowercase

February 7, 2022 Leave a Comment

To check if all characters in a string are lowercase, we can use the Python built-in string islower() function.

string_1 = "This is a String with SOME letters."
string_2 = "hello"

print(islower(string_1))
print(islower(string_2))

#Output:
False
True

When working with strings in Python, being able to get information about your variables easily is important. There are a number of built in string methods which allow us to get information and change string variables.

One such function which is very useful is the string islower() function. With the islower() function, we can determine if a string has all lowercase letters.

If the string has all lowercase letters, islower() returns “True”. Otherwise, if there is at least one capital letter, islower() returns “False”.

Below are a few examples of how to use the Python islower() function.

string_1 = "This is a String with SOME letters."
string_2 = "hello"

print(islower(string_1))
print(islower(string_2))

#Output:
False
True

Converting a String to Lowercase with the String lower() Python Function

Let’s say you are working a program where you need your inputs to be lowercase. Another useful string method related to the islower() Python function is the lower() function.

The lower() function in Python converts all letters of a string to lowercase.

Let’s see how the Python lower() function works with the example strings from above.

string_1 = "This is a String with SOME letters."
string_2 = "hello"

print(string_1.lower())
print(string_2.lower())

#Output:
this is a string with some letters.
hello

As you can see, now all of the letters are lowercase. If we pass these strings to islower(), both checks will come back “True”.

string_1 = "This is a String with SOME letters."
string_2 = "hello"

print(islower(string_1.lower()))
print(islower(string_2.lower()))

#Output:
True
True

Hopefully this article has been useful for you to understand how to check if all letters in a string are lowercase in your Python code.

Other Articles You'll Also Like:

  • 1.  Using Python to Check if Queue is Empty
  • 2.  Get Days in Month from Date in pandas DataFrame
  • 3.  pandas nlargest – Find Largest Values in Series or Dataframe
  • 4.  Python issuperset() Function – Check if Set is Superset of Another Set
  • 5.  Using Python to Generate Random String of Specific Length
  • 6.  pandas to_pickle – Write DataFrame to Pickle File
  • 7.  How to Save and Use Styles from Existing Word File With python-docx
  • 8.  Remove Character from String in Python by Index
  • 9.  How to Rotate a List in Python
  • 10.  Find Least Common Multiple of Numbers Using Python

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy