I have lists of the style:
[None, ..., None, "c", 1, 3, None, None, 4.3, "b", None, "4", None, ..., None]
that I would like to efficiently shorten to:
["c", 1, 3, None, None, 4.3, "b", None, "4"]
Straight forward I could do:
def _shorten(long_list):
start = False
short_list = []
for e in long_list:
if e:
start = True
if start:
short_list.append(e)
return short_list
reversed(_shorten(reversed(_shorten(long_list))))