It's not possible to have too many and
s in an if
statement. Rewrite the code like this and you can see where it's failing:
if vec.x <= area[0]:
printt("x1 fail", vec, area)
elif vec.x >= area[1]:
printt("x2 fail", vec, area)
elif vec.y <= area[2]:
printt("y1 fail", vec, area)
elif vec.y >= area[3]:
printt("y2 fail", vec, area)
else:
print("---Stuff in the way ---")
You can replace the printt()
statements with pass
statements once you figure out where in your code the issue is coming from.
As a general rule of thumb, you want to have only one boolean operator (and
or or
) per if condition in order to keep your code clean and readable. Writing deductive if
statements such as the one I wrote above is a great way to make code more readable and maintainable.