Hey everyone, I’ve been working on this program for a class assignment and I can’t seem to figure out this problem with my if statements and while loops. For some reason this code will only calculate for the first variable, or the “men” if statement. Attached are the two different ways I’ve tried to implement this and it still only calculates depending on which if statement I wrote first.
What I meant is that that makes it look like the right operand of or is evaluated first, or maybe the “simpler” operand. And that the left operand isn’t even evaluated there. Which is not the case, and they’d better not learn that (If they do, that would be the harm). The left operand is evaluated first, and the right operand might not even get evaluated at all. The end result is the same here, the if condition is true and evaluating it has no side effect (other than spending time) and the if suite is executed, but that’s not true in general.
(Btw it seems CPython optimizes the right side away during compilation, but that’s an implementation detail, and the left side still does get evaluated when the code runs.)