Check if a List is Empty or Not in Python

(Last Updated On: 25/01/2023)

Python Program to Check if a List is Empty or Not Using Not Operator

# Check if a List is Empty or Not in Python Using Not Operator
 
# Initialize list
list = [1,2,3,4,5,6,7,8,9]
 
# evaluating empty list object to False
if not list:
    #If List is Empty 
   print('Empty list')
else:
      #If List is not Empty 
   print('List is not Empty \n',list)

Output:

List is not Empty 
 [1, 2, 3, 4, 5, 6, 7, 8, 9]

Leave a Reply

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