Python Program to Check List is Empty or Not

Write a Python Program to Check whether the List is Empty or Not. There are three possible ways to check the list empty: using the built-in len() function, not operator, and direct comparison of [] within the if statement.

Using not Operator

We use the not operator to find the list is an empty list. 

list1 = []

if not list1:
    print("The List is Empty")
else:
    print("The List is Not Empty")
Python Program to Check List Is Empty or Not

Python Program to Check List is Empty or Not using len

We used the len function in this example that returns the list length. If the list length equals zero, then it’s an empty list; Otherwise, the list is not empty.

list1 = []

if len(list1) == 0:
    print("Empty")
else:
    print("Not Empty")
Empty

Direct Comparision

Apart from the approaches mentioned above, you can directly compare the list with [] to find whether the list is empty.

ls = []

if ls == []:
    print("True")
else:
    print("False")
True