Skip to content

Home

Flatten list

Flattens a list of lists once.

def flatten(lst):
  return [x for y in lst for x in y]

flatten([[1, 2, 3, 4], [5, 6, 7, 8]]) # [1, 2, 3, 4, 5, 6, 7, 8]

More like this

Start typing a keyphrase to see matching snippets.