I am doing some simple math recessively in a python script and am getting the follow warning:
"Warning: divide by zero encountered in divide".
To provide some context, I am taking two values and trying to find the percent difference in value (a - b) / a
and if its above a certain range then process it, but sometimes the value of a
or b
is zero.
I want to get rid of this specific warning (at a specific line) but all the information I have found so far seems to show me how to stop all warnings (which I do not want).
When I used to write shell scripts, I could do something like this
code...
more code 2 > error.txt
even more code
In that example, I would get the warnings for the 'code' and 'even more code' command but not for the second line.
Is this possible?