How do I check if a list is empty in Python?

Better Stack Team
Updated on January 26, 2023

You can check if a list is empty by using the len() function to check the length of the list. If the length of the list is 0, then it is empty.

Here's an example:

 
my_list = []

if len(my_list) == 0:
    print("The list is empty")
else:
    print("The list is not empty")

You can also use the following concise syntax to check if a list is empty:

 
if not my_list:
    print("The list is empty")
else:
    print("The list is not empty")

Both of these methods will work to check if a list is empty.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →

Reliability is the
ultimate feature

Delightful observability tools that turn your logs & monitoring into a secret weapon for shipping better software faster.

Explore Better Stack