Check if a List is Empty or Not in Python by Comparing an Empty List

(Last Updated On: 27/01/2023)

Python Program to Check if a List is Empty or Not by Comparing an Empty List

# Check If a List is Empty in python By Comparing with an Empty List

# empty list
list = []

# Checking whether the list object is equal to [](null list)
if list == []:
   print('List is Empty)
else:
   print('List is not empty\n',list)

Output:

List is Empty

Leave a Reply

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