paintedcupcakes - 5 months ago 25

Python Question

I am still working with bool logic.

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

`flag = False`

print(flag)

flag = flag or True

print(flag)

you get:

`>>False`

>>True

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)`

print(check)

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

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

Answer

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.