python – check if list is empty

In this post, we will see how to check if list is empty in python.
It is very easy to check if list is empty in python. You can use "not" to check if list is empty in Python.
Let’s understand with the help of simple example.

Output:

list1 is not empty
list2 is empty

You can also use Python len function to check if list is empty or not.

Output:

list3 is empty
list4 is not empty

That’s all about python check if list is empty.

Was this post helpful?

Leave a Reply

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