ZeroDivisionError: float division

i’m actually stuck with a stupid syntax problem.

here is a a piece of code i can’t debug:

kx = (neighbor[1] + agent[1]) / (dx - (neighbor[1] + agent[1]))

in this line, ‘neighbor[1]’ and ‘agent[1]’ are both integers and ‘dx’ is a float so it gives me the following error: ‘ZeroDivisionError: float division’.

And it is the same if i convert them into floats by float() function.

The problem is that you are trying to divide by zero: i.e.

3/0, 10/0, 100/0, etc.

This is not a defined mathematical capability (in all math, not just your computer) so it throws an error.

In your code it results when dx = neighbor[1] + agent[1] (when dx- (neigbor[1] +agent[1]) = 0).

Its not an error with types (int vs. float)

Thanks for that, i believed that it was a problem of float conversion:no:

i will be able to post a wip soon

thanks again