I have been getting my head around to do the recursion without using any global variable. If am passing the lists the lists of lists ... and resultantly, i should have all the elements from the input in a single list. The problem is every time i call the function the list is declared from the start.
def unnest (alist):
List_ = list()
for elements in alist:
if type(elements) == list:
unnest(elements)
else:
List_.append(elements)
return List_
if __name__=='__main__':
unnest([1,2,[3,4,5,[6,7,[8,9,[10,11,[12,[13,[14]]]]]]]])