# Python List Equality | Program to check if two given matrices are identical

• Difficulty Level : Basic
• Last Updated : 21 Nov, 2018

We are given two square matrices of same order. Check if two given matrices are identical.

Examples:

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

```Input :     A = [ [1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3],
[4, 4, 4, 4]]

B = [ [1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3],
[4, 4, 4, 4]]

Output:    Matrices are identical
```

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

We have existing solution for this problem please refer C Program to check if two given matrices are identical link. In python any iterable object is comparable so we can solve this problem quickly in python with the help of List Equality.

 `# Function to check if two given matrices are identical`` ` `def` `identicalMatrices(A,B):`` ` `     ``if` `A``=``=``B:``        ``print` `(``'Matrices are identical'``)``     ``else``:``        ``print` `(``'Matrices are not identical'``)`` ` `# Driver program``if` `__name__ ``=``=` `"__main__"``:``    ``A ``=` `[ [``1``, ``1``, ``1``, ``1``],``          ``[``2``, ``2``, ``2``, ``2``],``          ``[``3``, ``3``, ``3``, ``3``],``          ``[``4``, ``4``, ``4``, ``4``]]``  ` `    ``B ``=` `[ [``1``, ``1``, ``1``, ``1``],``          ``[``2``, ``2``, ``2``, ``2``],``          ``[``3``, ``3``, ``3``, ``3``],``          ``[``4``, ``4``, ``4``, ``4``]]``    ``identicalMatrices(A,B)`

Output:

```Matrices are identical
```

My Personal Notes arrow_drop_up