Add two matrices in python

前端 未结 4 1470
独厮守ぢ
独厮守ぢ 2020-12-17 15:45

I\'m trying to write a function that adds two matrices to pass the following doctests:

  >>> a = [[1, 2], [3, 4]]
  >>> b = [[2, 2], [2, 2]         


        
4条回答
  •  情话喂你
    2020-12-17 16:21

    One more solution:

    map(lambda i: map(lambda x,y: x + y, matr_a[i], matr_b[i]), xrange(len(matr_a)))
    

提交回复
热议问题