'int' Object is not subscriptable

Asked

Viewed 257 times

0

I have a problem with the following code:

for x0 in range(len(matriz)):  # Abaixo foi aplicada a fórmula de transformações lineares para linhas e colunas.
    xn = transformação[0][0] * x0 + transformação[0][1] * x0 + y0 + transformação[0][2] % (len(matriz))
    for y0 in range(len(matriz[0])):
        yn = transformação[1][0] * x0 + transformação[1][1] * y0 + transformação[1][2] % (len(matriz[0]))
        matrizt[xn][yn] = matriz[x0][y0]
        y0 += 1
    y0 = 0
    x0 += 1

The error is as follows:

'int' Object is not subscriptable

More specifically, the error is in relation to the line:

xn = transformação[0][0] * x0 + transformação[0][1] * x0 + y0 + transformação[0][2] % (len(matriz))
  • 3

    It means that transformação[0] is returning an integer. So transformação is not a matrix with two dimensions, but only a vector/matrix of one dimension. Without details of the creation of this variable, I can do nothing more than I have already said

  • Thank you, Jefferson. I’ll try to apply.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.