ls = [[1], [1, 2], [1, 2, 3], [], [2], [2, 3], [], [], [3]]
Is there any python list method that will enable me to remove all the similar items at once. For example, I have a 2d list 'ls' which has three empty list items []. I want to remove all the empty list items at once.
I know it can be done with 'remove' and 'loop.' But is there any method to do the operation at once?
To be simple: I want all the '[]' to be deleted. And thus the answer would be like this.
[[1], [1, 2], [1, 2, 3], [2], [2, 3], [3]]