python sum 2D array code example
Example 1: 2d array python initialize
[[element] * numcols] * numrows
Example 2: how to add elements in 2d array in python
n,m=int(input()),int(input())
for i in range(0,n):
for j in range(0,m):
a[i].append(int(input()))
Example 3: 2d array python initialize
>>> b = [['a']*3]*3
>>> b
[['a', 'a', 'a'], ['a', 'a', 'a'], ['a', 'a', 'a']]
>>> b[1][1]
'a'
>>> b[1][1] = 'b'
>>> b
[['a', 'b', 'a'], ['a', 'b', 'a'], ['a', 'b', 'a']]