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]