This is only for self learning of the concept and might not have practical use
My question is
can I use only recursive function and list comprehension to flatten a unknown level of nested list?
If 1 is possible, can I only use list comprehension + lambda function to get the same purpose?
So far this all I can get but it seems not working.
l=[1,[2,3],[4,5,[6,7,8,9]]] # assuming unknown level of nesting
def fun_d(x):
return [fun_d(e) if isinstance(e,list) else e for e in x]
fun_d(l)
Out[25]: [1, [2, 3], [4, 5, [6, 7, 8, 9]]]