How to check if the list is empty in python?

A list is a data structure, or it can be considered as a container that can be used to store multiple data at once. A list will be ordered and there will be a definite count of it.
We’ll see here how to check if the list is empty or not.
e.g.,
l=[] if len(l)==0: print("list is empty") else: print("list is not empty")

e.g.,
l=[] if l==[]: print("list is empty") else: print("list is not empty")

This is how we can check if the list is empty or not.
Subscribe
Login
Please login to comment
0 Discussion