How to check if the list is empty in python?
![](https://pythonpoint.net/wp-content/uploads/2020/11/Cream-Mountain-Photo-Blog-Banner-2.jpg)
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")
![](https://pythonpoint.net/wp-content/uploads/2020/11/Screenshot-845-1024x592.png)
e.g.,
l=[] if l==[]: print("list is empty") else: print("list is not empty")
![](https://pythonpoint.net/wp-content/uploads/2020/11/Screenshot-848-1024x545.png)
This is how we can check if the list is empty or not.
Subscribe
Login
Please login to comment
0 Discussion