Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

flatten nested list

def flatten(x):
    if isinstance(x, list):
        return [a for i in x for a in flatten(i)]
    else:
        return [x]
 
PREVIOUS NEXT
Tagged: #flatten #nested #list
ADD COMMENT
Topic
Name
5+7 =