Write a python Program to Flatten a List without using Recursion


Topic: Write a python Program to Flatten a List without using Recursion

Solution

a=[[1,[[2]],[[[3]]]],[[4],5]]
flatten=lambda l: sum(map(flatten,l),[]) if isinstance(l,list) else [l]
print(flatten(a))



List all Python Programs