-1

I have a list similar to this

numbers=[['3','4','5'],['',''],['6','7','8']

and i want to remove the

['','']

sublist completely so the final numbers list should look like

numbers=[['3','4','5'],['6','7','8']]

ive tried to use

numbers[index].remove('')

but thats just giving me a list index out of range error

Austin Tucker
  • 25
  • 1
  • 5

1 Answers1

0
In [73]: L = [['3','4','5'],['',''],['6','7','8']]

In [74]: dels = []

In [75]: for i,sub in enumerate(L):
   ....:     if all(e=='' for e in sub):
   ....:         dels.append(i)
   ....:         

In [76]: for i in dels[::-1]:
   ....:     L.pop(i)
   ....:     

In [77]: L
Out[77]: [['3', '4', '5'], ['6', '7', '8']]
inspectorG4dget
  • 110,290
  • 27
  • 149
  • 241