Operator Precedence/Boolean Logic
Random832
random832 at fastmail.com
Wed Jun 22 10:10:38 EDT 2016
On Tue, Jun 21, 2016, at 23:40, Elizabeth Weiss wrote:
> Hi There,
>
> I am a little confused as to how this is False:
>
> False==(False or True)
>
> I would think it is True because False==False is true.
"False or True" is True, and then it reduces to "False == True" which is
false.
There's no "x == (y or z)" construct to compare x separately to both y
and z, the "or" will evaluate to the first one that's true and then is
used in the rest of the expression. If you wanted to write "x == y or x
== z" with only a single x, you'd do "x in (y, z)".
More information about the Python-list
mailing list