-1

When comparing multiple conditions with 'AND', will the comparisons stop if the first condition is not met?

for example; if 'A' AND 'B': if not 'A', will 'B' be considered?

To remove the negative points for duplication... If one knew that the problem was called short-circuiting, it could have easily been searched, but the first condition was False in this case and short-circuited the second condition, the search. This was a question of which term to search and not on of how the term functions.

jsfa11
  • 483
  • 7
  • 19

1 Answers1

0

Yes. This concept is called short circuiting.

This is easily seen in code.

def false():
    print('false')
    return False

def true():
    print('true')
    return True

print('false() and true()')
if false() and true():
    pass

# true is not printed

print('true() and false()')
if true() and false():
    pass

# both functions execute
Ben
  • 5,952
  • 4
  • 33
  • 44