filbert
filbert copied to clipboard
Compound Boolean Expressions don't work properly
This is from the Filbert Interactive Testing page:
a = 5
b = 5
if a == b > 4:
print('Compound Works')
else:
print('Compound Fails')
if a==b and b>4:
print('And Works')
else:
print('And Fails')
Output:
Compound Fails
And Works
Both should work.
I tested the first, and apparently the parser does this:
(5==5)>4
which gives 1>4
, which is false.
Python3 parses it as ternary conditionals, like so:
5==5 and 5>4
Nice, thanks for the reduced repros.
https://docs.python.org/3.4/library/stdtypes.html#comparisons