This and That (or This, But Not That!)


what's my mistake/s?


The key here is to understand the order in which the Python interpreter evaluates "not", "and", "or". These logical operators have a precedence defining the order in which they are evaluated, similar to the way in which mathematical operators such as "*", "+", etc. are evaluated in a certain order. In the case of logical operators, first "not" is evaluated, then "and", then "or" on their respective neighboring arguments. Using parentheses "()" can change this ordering or make it more explicit.

The console indicates that you got bool_two incorrect, so let's examine it.

bool_two = False and not True or True

Using the rules discussed above, we can use parentheses to highlight this precedence and simplify. The following expressions are all equivalent:

bool_two = False and not True or True
= False and (not True) or True
= (False and (not True)) or True
= (False and False) or True
= False or True
= True


Cool Breakdown! Very logical.


Thanks for the breakdown.