Check if a List is Empty or Not in Python Using NumPy Module

(Last Updated On: 27/01/2023)

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

# Check If a List is Empty in python Using NumPy Module

# importing NumPy module
import numpy as np

# empty list
list = []

# converting the list to NumPy array
resultarray = np.array(list)

# checking whether the array size is equal to 0
if resultarray.size == 0:
   print('Empty list')
else:
   print('List is not Empty')

Output:

Empty list

Leave a Reply

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