copy of GGKSJNHQ8 ()
216 bytes of Python
Created 3 hours ago
— expires in 7 days
Viewed
66 times
https://dpaste.com/E2UURWVB8
| def flatten(items):
for item in items:
children = item.pop('children', None)
yield item
if children:
yield from flatten(children)
flat_list = list(flatten(nested_list))
|
def flatten(items):
for item in items:
children = item.pop('children', None)
yield item
if children:
yield from flatten(children)
flat_list = list(flatten(nested_list))