Issue
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
'''
Solution
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.
board
is not a function, nested python list
In this case, just change()
to[]
to access array.board
is 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.
Answered By - ulismoon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.