I have searched for this but it's in other languages like Python or R (?). I have lists inside a list and I would like to remove the empty list. For example:
[ [abc,def], [ghi], [], [], [jkl, mno]]
I would like:
[ [abc,def], [ghi], [jkl, mno]]
How do I remove empty list from a list? Thanks!
Short answer: You can remove all empty lists from a list of lists by using the list comprehension statement [x for x in list if x] to filter the list.
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