Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python flatten a list of lists

from collections.abc import Iterable

def flatten(l):
    for el in l:
        if isinstance(el, Iterable) and not isinstance(el, (str, bytes)):
            yield from flatten(el)
        else:
            yield el
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #flatten #list #lists
ADD COMMENT
Topic
Name
7+1 =