0

In python, if I have the following code:

a = True
b = True

if (a == True) or (b == True):
    // Do stuff

My question is, in that if statement, does it check to see if b is True after it's already seen that a is True? Or does it execute the code in the if statement as soon as it sees that a is True

Mark Cook
  • 179
  • 1
  • 11
  • 1
    See the linked question's answers. No, the `b == True` part is not evaluated if `a == True` is true. (This is true of most, but not all, programming languages in terms of their *logical* "and" and "or" operators.) – T.J. Crowder Mar 01 '19 at 18:23
  • 1
    Thank you very much, I wasn't aware that it was called short-circuiting. Thank you very much for the responses. – Mark Cook Mar 01 '19 at 18:23
  • 1
    :-) Yeah, I saw the question and (not being a Python guy) was able to find the answer because I happened to know what it's called. Happy coding! – T.J. Crowder Mar 01 '19 at 18:24

0 Answers0