i have a nested list. For example:
['a', ['b', 'c', ['e', 'd']]]
I want to get a list which contains that list and all sublists separately as elements. So the expected results is:
[['a', ['b', 'c', ['e', 'd']]], ['b', 'c', ['e', 'd']], ['e', 'd']]
i wrote this function:
def extract(lst):
result = []
result.append(lst)
for i in lst:
if isinstance(i, list):
result.append(i)
extractt(i)
return result
But the result is not what expected. how could i fix it?