python comparing two matrices
python
Solution
What's wrong with `a1 == a2`?
In [1]: a1=[[1,44,55],
...: [2,33,66],
...: [3,77,91]]
In [2]: a2=[[1,44,55],
...: [2,45,66], # <- second element differs
...: [3,77,91]]
In [3]: a1 == a2
Out[3]: False
In [4]: a1=[[1,44,55],
...: [2,33,66],
...: [3,77,91]]
In [5]: a2=[[1,44,55],
...: [2,33,66],
...: [3,77,91]]
In [6]: a1 == a2
Out[6]: True
Problem
In the below shown matrices i want to match the first element in both the matrices. If the first element is equal then i need match the second element from both the matrices and so on.. if the elements are same then print "same" else print "not same".... My question is how this in the optimal way also for m*n where m=n always ``` for i in a1: for j in a2: if i!=j: break else: //compare the next corresponding columns and print "same" or "not same" a1=[1,44,55],[2,33,66],[3,77,91] a2=[1,44,55],[2,45,66],[3,77,91] OR a1=[1,44,55] [2,33,66] [3,77,91] a2=[1,44,55] [2,45,66] [3,77,91] ```