Logo

Programming-Idioms

History of Idiom 26 > diff from v81 to v82

Edit summary for version 82 by Anon:
New Python implementation by user [Anon]

Version 81

2021-08-03, 14:32:44

Version 82

2021-08-16, 13:01:08

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
x = [[0]*n for i in range(m)]
Comments bubble
You can't use the multiplication idiom for the outer array, because, it would just duplicate the references to the inner arrays.