+ 3
Tell me what's the len(A) and len(A[0]) ? I know len but i dont understand the A[0] in this code
A = [[12,7,3], [4,5,6], [7,8,9]] B = [[5,8,1], [6,7,3], [4,5,9]] result = [[0,0,0], [0,0,0], [0,0,0]] for k in range(len(A)): for j in range(len(A[0])): result[k][j] = A[k][j]+B[k][j]
3 Answers
+ 1
A[0] is referring to [12,7,3]
0
len (A [0]) indicates that it is taking the length of the first element in the array, so the loop starts at 0 through 3, which is the length of the first element.
A[0] = [12, 7, 3]