Flatten Nested Array

Flattens a nested array into a single array.

Contributed by @itsbrunodev

python
nested = [[1, 2], [3, 4], [5]]
flattened = [item for sublist in nested for item in sublist] # [1, 2, 3, 4, 5]
GitHubEdit on GitHub