How are you trying to debug the code? I suggest using print statements that print out the values of all the subexpressions so you can see which one(s) are not evaluating the way you want.

You may...