SteveTz
SteveTz

Reputation: 232

How can I check if the multidimensional array is empty

I have created the array like this:

a = np.empty((2,3), dtype=object)

How can I check if it's empty? I have used the following methods without any success.

a = np.empty((2,3), dtype=object)
#1:
if a == []: 
   print("Empty list!")
else:
   print('Not empty')

#2:
if not a:
   print("List is empty")
else:
   print('Not empty')

#3:
if a:
   print('Not empty')

Upvotes: 0

Views: 520

Answers (1)

FugitiveMemories
FugitiveMemories

Reputation: 183

For python3, this is one of the moves:

if a.all()==None: 
   print("Empty list!")
else:
   print('Not empty')

Upvotes: 0

Related Questions