locode
  • Questions
  • Leaderboard
  • Blog

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

asked16 years ago
last updated3 years ago
viewed3.9m times
Up Vote5.1kDown Vote

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]?


python list comprehensions; compressing a list of lists? Flatten an irregular (arbitrarily nested) list of lists

pythonlistmultidimensional-arrayflatten
edited
10 Sep at 09:22
from the blog
Generating the PvQ Leaderboard
Getting Help in the Age of LLMs
About
Blog
Archive
Privacy
powered by blazor vue
Site Design © 2024 locode.dev, content licensed under CC BY-SA.