Logo

Programming-Idioms

History of Idiom 26 > diff from v83 to v84

Edit summary for version 84 by programming-idioms.org:
[Python] Comment from user Anon

Version 83

2021-08-16, 13:02:00

Version 84

2021-08-16, 19:55:33

Idiom #26 Create a 2-dimensional array

Declare and initialize a matrix x having m rows and n columns, containing real numbers.

Idiom #26 Create a 2-dimensional array

Declare and initialize a matrix x having m rows and n columns, containing real numbers.

Variables
x,m,n
Variables
x,m,n
Extra Keywords
2d
Extra Keywords
2d
Code
[[0] * n for _ in range(m)]
Code
[[0] * n for _ in range(m)]
Comments bubble
Do not just "multiply by m", which would duplicate the references to the inner arrays.