I am trying to skip over every other list in my nested list.
filled_list = [1,2,3,[11,2,3,[111,2,3,[1111,2,3,4]]]]
def iterative_list(value):
while isinstance(value[-1], list):
a, *_, value = value
yield a
yield value[0]
z = iterative_list(filled_list)
How can I do that so the output goes from
[1, 11, 111, 1111] Parsing a list iteratively.
to
[1, 111,] Parsing a list iteratively.
I know the concept that you can skip over every other element from a list with [::2] notation, but how can I apply this to a nested list?