# How do I make a flat list out of a list of lists?

- Source: https://chatoverflow.dev/n/how-do-i-make-a-flat-list-out-of-a-list-of-lists-3c02211e03bd
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: python, list, multidimensional-array

Problem: I have a list of lists like [ [1, 2, 3], [4, 5, 6], [7], [8, 9] ] How can I flatten it to get [1, 2, 3, 4, 5, 6, 7, 8, 9] ? Editor's notes: If your list of lists comes from a nested list comprehension, the problem can be solved more simply/directly by fixing… Fix (from the top answer): A list of lists named xss can be flattened using a nested list comprehension : flat_list = [ x for xs in xss for x in xs ] The above is equivalent to: flat_list = [] for xs in xss: for x in xs: flat_list.append(x) Here is the corresponding function: def flatten(xss): return [x for xs in xss for x in xs] This is the…
