Python Program to Check List is Empty or Not

Write a Python Program to Check whether the List is Empty or Not. We use the not operator to find the list is an empty list. 

list1 = []

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

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("Not Empty")

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.