Home > Net >  How can I do to check if a list of lists is empty?
How can I do to check if a list of lists is empty?

Time:10-28

I have this list :

a = [[], [], []]

and that one :

b = [[], [2], []]

I would like to check if a and b are empty. I mean for me a is empty and b is not. How can I do that ?

Thank you very much !

CodePudding user response:

Using any:

>>> any([[], [], []])
False
>>> any([[], [2], []])
True

CodePudding user response:

You could check for "empty" using not any

>>> not any(a)
True
>>> not any(b)
False
  • Related