Convert multi-dimensional list to a 1D list in Python

前端 未结 7 665
萌比男神i
萌比男神i 2020-12-05 00:14

A multidimensional list like l=[[1,2],[3,4]] could be converted to a 1D one by doing sum(l,[]). Can anybody please explain how that happens?

<
7条回答
  •  有刺的猬
    2020-12-05 00:46

    The + operator concatenates lists and the starting value is [] an empty list.

提交回复
热议问题