You seem to have confused python's or
and |
.
Understandable, given that the or operator in many langages is |
(or more commonly ||
).
This page lists python's operators
Try your example again, but using or
instead of |
if (a or b == 0) or c == 0:
If I'm reading your question correctly however, I think you're trying to do this;
if (a == b == 0) or c == 0:
This is the shortcut-syntax in python for checking if both a
and b
is equal to 0.
EDIT: As per clarification;
Requirement is to confirm 0 is not passed as an argument to the function
If you can safely assume that your arguments are going to be ints, then I would take the following approach:
if a and b and c:
pass # valid
else:
pass # invalid
0
is falsey - so lets use the fact. Otherwise, there isn't really a 'shortcut' way to do what you're doing.