a = []
if not a:
print("List is empty")
How to check for empty array in python
code
# empty list & non-empty list
empty_list = []
non_empty_list = [1, 2, 3, 4]
# check if list is empty
def check_list_empty(lst):
if len(lst) == 0:
print('The List is empty')
else:
print('The list is not empty')
# pass in the lists to check_list_empty
check_list_empty(empty_list)
check_list_empty(non_empty_list)
#Output
The list is empty
The List is not empty