How to create increment 2D list
if input = 3 then output is
[ 1,0,0],
[1,2, 0],
[1,2,3]]
- if input = 4 then output is
[[1,0,0,0],
[1,2,0,0],
[1,2,3,0],
[1,2,3,4]]
Code is below to print every number to Zero
- How to increment of [x][y]
w = 3
matrix = [[0 for x in range(w)] for y in range(w)]
matrix
or
rows = 3
cols = 3
matrix = []
for i in range(rows):
row = []
for j in range(cols):
row.append(0)
matrix.append(row)
print(matrix)