# Python Program to Add Two Matrices

## Add Two Matrices in Python

To add two matrices in python, you have to choose two matrix and another empty matrix. The third or empty matrix is used to store the addition result of the two matrices as shown in the program given below.

## Python Programming Code to Add Two Matrices

Following python program adds two matrices to print the addition result of the two matrices:

```# Python Program - Add Two Matrices

matrix1 = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
matrix2 = [[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]
rmatrix = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
for i in range(len(matrix1)):
for j in range(len(matrix1)):
rmatrix[i][j] = matrix1[i][j] + matrix2[i][j]
for r in rmatrix:
print(r)
```

Here is the sample run of the above Python program shows how to add two matrices:

Adding of two matrices can be performed using matrix1 + matrix2 or 1+10, matrix1 + matrix or 2+11, matrix1 + matrix2 or 3+12, matrix1 + matrix or 4+13 and so on. Here the result of additing the matrix1 and matrix2 will be the third matrix, that is rmatrix holds 11, rmatrix holds 13 and so on. Here is the same program on python shell: ### Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:

Tools
Calculator