0

This question is a bit tricky for me.The input is a list of lists like:

matmult([[1,2],[3,4]],[[1,0],[0,1]]) 

Output:

matmult([[1,2],[3,4]],[[1,0],[0,1]])

[[1,2],[3,4]]

matmult([[1,2,3],[4,5,6]],[[1,4],[2,5],[3,6]])

[[14, 32], [32, 77]]

Here's my broken code for the same:

def matmult(m1,m2):
    x=0
    y=0
    a=0
    for value in range(0,len(m1)):
        for other in range(0,len(m2)):
            a=m1[value]*other[value]+other[value]*m2[value]
            return(a)

where matmult is the name of my function.

Do help me.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Dhruv Marwha
  • 1,064
  • 2
  • 14
  • 26
  • its all wrong first try to understand the concept of matrix multiplication to implement in python look here http://stackoverflow.com/questions/10508021/matrix-multiplication-in-python – rdRahul Aug 10 '16 at 17:32
  • Please describe the exact problem you're having (including traceback if you're getting an error). – glibdud Aug 10 '16 at 20:57
  • Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation. [Minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) applies here. We cannot effectively help you until you post your code and accurately describe the problem. – Prune Aug 11 '16 at 17:37

0 Answers0