paintedcupcakes paintedcupcakes - 5 months ago 25
Python Question

Why does this bool expression with 'or' return True?

I am still working with bool logic.

I have this snippet and I don't understand why the result comes out True.

flag = False
flag = flag or True

you get:


Why is this happening? I am not sure how this works.

Is or supposed to give you any instance where the expression is True?

I get why this happens:

check = (7 > 60) or (7 < 10)

7 is less than 10, so the check expression is True

Thanks for the explanation. Just trying to work out bools in my head.


Because in logic,

(False or True) == True

The or expression is true, if any of the two arguments is true. That is the case here.