1
In my code, I create two matrices, and compare the elements of the two in each position. The largest element at each position is selected and placed in the third matrix. When I finish all the checking, I have the loop to print the third matrix, however, I get the error of Typeerror: 'int' Object is not subscriptable - in the loop print code line:
for i in range(4):
print(m3[i])
My complete code below:
m1 = []
m2 = []
m3 = []
for i in range(4):
linha = []
for j in range(4):
linha.append(int(input('Primeira Matriz - Insira o valor ['+ str(i) +','+ str(j) +']:')))
m1.append(linha)
for i in range(4):
linha = []
for j in range(4):
linha.append(int(input('Segunda Matriz - Insira o valor ['+ str(i) +','+ str(j) +']:')))
m2.append(linha)
maior = 0
for i in range(4):
for j in range(4):
if m1[i][j] > m2[i][j]:
m3 = m1[i][j]
else:
m3 = m2[i][j]
for i in range(4):
print(m3[i])
Thanks for the help,corrected and worked perfectly
– Marco Aurélio Lopes Júnior