I get a weird result and I try to apply the and
or the or
operator to 2 Boolean lists in python. I actually get the exact opposite of what I was expec
Both lists are truthy because they are non-empty.
Both and
and or
return the operand that decided the operation's value.
If the left side of and
is truthy, then it must evaluate the right side, because it could be falsy, which would make the entire operation false (false and
anything is false). Therefore, it returns the right side.
If the left side of or
is truthy, it does not need to evaluate the right side, because it already knows that the expression is true (true or
anything is true). So it returns the left side.
If you wish to perform pairwise comparisons of items in the list, use a list comprehension, e.g.:
[x or y for (x, y) in zip(a, b)] # a and b are your lists