Home python Error while creating array: SyntaxError: can't assign to function call

Error while creating array: SyntaxError: can’t assign to function call

Author

Date

Category

Good afternoon, I’m trying to split one two-dimensional array into three smaller ones, but the last line gets an error “SyntaxError: can’t assign to function call”. Python 3.6 version
Please tell me how to fix it

N = len (matrix)
  M = len (matrix [0])
  n = (N) // 3
  A = np.zeros ((n, M))
  for i in range (n):
    for j in range (M):
      A (i, j) = matrix (i, j)

Answer 1, authority 100%

A little bit wrong:

A (i, j) = matrix (i, j)

And this is correct:

A [i, j] = matrix [i, j]

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions