Check if multiple dimension Python array is empty

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Check if multiple dimension Python array is empty



I have a function that can return randomly shaped array like:


[[1], 2, [[3, 4], , [[5]]]



I need to check if the result array is empty and I can't use numpy or any other third party library.
Unfortunately,


if : ...
>>> False



which is fine, but


if [,]:...
>>> True



and I want this result to be false, so I came up with this:


def isEmpty(a):
return all([isEmpty(b) for b in a]) if isinstance(a, list) else False



Is there a built in way to get this result ?
If not this post might be usefull to someone somehow.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

Future solutions