User can enter any value & the program will print the final matrix. Here I have used matrix addition to display the matrix in 3x3 form. I want to know is there any short way to still get our matrix in 3x3 form?
Here's my code:
print('Consider matrix mij with i rows & j colomns:')
a=int(input('Enter m11 value: '))
b=int(input('Enter m12 value: '))
c=int(input('Enter m13 value: '))
d=int(input('Enter m21 value: '))
e=int(input('Enter m22 value: '))
f=int(input('Enter m23 value: '))
g=int(input('Enter m31 value: '))
h=int(input('Enter m32 value: '))
i=int(input('Enter m33 value: '))
X=[[a,b,c],
[d,e,f],
[g,h,i]]
Y=[[0,0,0],
[0,0,0],
[0,0,0]]
print('Your matrix is:')
for i in range(len(X)):
for j in range(len(X[0])):
X[i][j]=X[i][j]+Y[i][j]
for r in X:
print(r)