<Ч
Size: a a a
<Ч
TD
matrix_1 = [[0, 2, 4, 6],
[1, 5, 9, 13],
[3, 10, 17, 19]]
matrix_2 = [[1, 4, 6 ,8],
[2, 3, 5, 17],
[0, 28, 24, 19]]
solution = []
for x,y in zip(matrix_1, matrix_2):
for mem1, mem2 in zip(x,y):
solution.append(mem1+mem2)
#solution
= [1, 6, 10, 14, 3, 8, 14, 30, 3, 38, 41, 38]
Как можно сделать solution в виде списка со вложенными списками, как matrix? Знаю что можно в numpy за 1 строчку, но надо без негоМ
М
М
🅹
matrix_1 = [[0, 2, 4, 6],
[1, 5, 9, 13],
[3, 10, 17, 19]]
matrix_2 = [[1, 4, 6 ,8],
[2, 3, 5, 17],
[0, 28, 24, 19]]
solution = map(lambda x: [x[0][i]+x[1][i] for i in range(4)], zip(matrix_1, matrix_2))
print(list(solution))
RC
RC
ᅠ
ᅠ
ᅠ
RC
ᅠ
RC
М
ᅠ
RC
¯
ᅠ