One-Level Flatten

Sometimes data arrives nested, such as several small lists inside one larger list. Write a function flatten that removes only one level of nesting and collects all elements into a single list. Keep the original order: first the elements of the first inner list, then the second, and so on.

Примеры

Ввод
[[1, 2], [3, 4], [5]]
Вывод
[1, 2, 3, 4, 5]
Ввод
[]
Вывод
[]
Ввод
[[1]]
Вывод
[1]

Нужно реализовать

def flatten(nested: list[list]) -> list:

Теги

listsarray
PostgreSQLv16

Qui apparirà il risultato dell'esecuzione del codice

Visible tests
1
Input
[[1,2],[3,4],[5]]
Expected[1,2,3,4,5]
2
Input
[]
Expected[]
3
Input
[[1]]
Expected[1]
4
Input
[[],[],[]]
Expected[]
5
Input
[[1,2,3]]
Expected[1,2,3]
6
Input
[[7],[8,9]]
Expected[7,8,9]
Focus radio
Paused · SomaFM · Fluid