How to make a flat list out of list of lists in Python?

DWQA QuestionsCategory: PythonHow to make a flat list out of list of lists in Python?
Editor Staff asked 2 months ago

whether there is a shortcut to make a simple list out of list of lists in Python.
I can do that in a for loop, but maybe there is some cool “one-liner”? I tried it with reduce(), but I get an error.
Code

l = [[1, 2, 3], [4, 5, 6], [7], [8, 9]]
reduce(lambda x, y: x.extend(y), l)

Error message

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <lambda>
AttributeError: 'NoneType' object has no attribute 'extend'