How to create nested lists in python?

前端 未结 5 387
无人及你
无人及你 2021-01-13 01:14

I know you can create easily nested lists in python like this:

[[1,2],[3,4]]

But how to create a 3x3x3 matrix of zeroes?

[[         


        
5条回答
  •  悲哀的现实
    2021-01-13 01:44

    Or use the nest function defined here, combined with repeat(0) from the itertools module:

    nest(itertools.repeat(0),[3,3,3])
    

提交回复
热议问题