'int' Object Is Not Callable Only Appears Randomly
Sometimes this code works just fine and runs through, but other times it throws the int object not callable error. I am not real sure as to why it is doing so. for ship in ships:
Solution 1:
You are trying to call (use the ..(...)
syntax) on an integer here:
ship.location[size][1]((ship.location[0][0], \
ship.location[0][1] - size))
ship.location[size][1]
is an integer, and you are trying to call it by passing in the tuple (ship.location[0][0], ship.location[0][1] - size)
as the arguments.
Your code makes this mistake in more than one place; other examples include
ship.location[size][1]((ship.location[0][0], \
ship.location[0][1] + size))
and
ship.location[size][1] \
((ship.location[0][0] - size, \
ship.location[0][1]))
and
ship.location[size][1] \
((ship.location[0][0] + size, \
ship.location[0][1]))
The backslash there still joins the physical line into a logical line, so the (...)
calls still apply to the integers.
It is not clear to me what you wanted to do with that expression, however, so I can't offer any remedy here.
Solution 2:
In any spot where the code looks like this:
ship.location[size][1]((ship.location[0][0], \
ship.location[0][1] - size))
The simple solution was that I needed to assign it to the location:
ship.location[size] = ((ship.location[0][0],ship.location[0][1] - size))
Post a Comment for "'int' Object Is Not Callable Only Appears Randomly"