filbert icon indicating copy to clipboard operation
filbert copied to clipboard

Compound Boolean Expressions don't work properly

Open nemoyatpeace opened this issue 10 years ago • 2 comments

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.

nemoyatpeace avatar Jul 16 '14 00:07 nemoyatpeace

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

danieltanfh95 avatar Jul 16 '14 02:07 danieltanfh95

Nice, thanks for the reduced repros.

https://docs.python.org/3.4/library/stdtypes.html#comparisons

differentmatt avatar Jul 16 '14 02:07 differentmatt