I was checking a project that i have to turn in (it's a battleship game) and for some reason when it runs "through" the section bellow it says "can't assign function call" when it's a copy paste of a piece of just above (with a couple changes) and it gives no error. Do you see the error?
'''
elif y == "v":
if a + 3 > 4:
return "put the boat higher, here it leaves the board"
else:
board(a)(b) = "V"
a = a + 1
board(a)(b) = "V"
a = a + 1
board(a)(b) = "V"
return board
'''
2 Answers 2
First of all, I highly recommend you to use python 3, read this.
And I don't know what is board, so I will answer for two cases.
boardis not a function, nested python list
In this case, just change()to[]to access array.boardis a function
In this case, you're definitely wrong. board() is a function call and will return function result. So, you cannot assign "V" into your function call. This is pretty natural.
Now, check out what is your case and happy coding.
Comments
Maybe instead of accessing a matrix with the [] operator you are making calls with (). So try replacing board(a)(b) with board[a][b] but without more information is really hard to tell.
board(a)(b) = "V"should probably beboard[a][b] = "V", if you're accessing elements of a data structure.