Can I do this in Python:
if not (list1, list2, list3):
...
To check if all given lists are empty?
If not how else would I do it?
A tuple that has at least one element is truthy in boolean context. This means that not (list1, list2, list3)
is always False.
Since empty lists are falsy, you can use the built-in any
function as shown below
if not any([list1, list2, list3]):
# ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With