Build Your Own Zip

Python's zip groups elements that have the same index across several lists. Given a list of lists rows, where inner lists may have different lengths, build those index-based groups yourself. Return a list of groups, stopping at the shortest inner list; if there are no input lists, return an empty list.

Примеры

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

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

def my_zip(rows: list) -> list:

Теги

listsarray
PostgreSQLv16

Tady se objeví výsledek běhu kódu

Visible tests
1
Input
[[1,2,3],[4,5,6]]
Expected[[1,4],[2,5],[3,6]]
2
Input
[[1,2,3],[4,5]]
Expected[[1,4],[2,5]]
3
Input
[]
Expected[]
4
Input
[[1],[2],[3]]
Expected[[1,2,3]]
5
Input
[[1,2],[]]
Expected[]
6
Input
[["a","b"],["c","d"],["e","f"]]
Expected[["a","c","e"],["b","d","f"]]
Focus radio
Paused · SomaFM · Fluid