0
why print(2<10<9) evaluates to False
print(2<10<9) print(True<9) """ Output: False True """ """ Less operator associativity is from left to right. As per this rule, 2<10 is evaluated first and should give True then the result of above should have been evaluated second i.e True <9 but actually 10<9 is evaluated second why ? """
3 ответов
+ 4
10<9 is evaluated second because thats the fixed order of precedence(i.e.,preference) for the < operators.
+ 4
Actually it is non associative. This is a Python feature called chained comparisons https://docs.python.org/3/reference/expressions.html#comparisons
0
Thanks everyone i got it