-4
>>> 0 < 10 != 1 < 5
True

Why is it?? 0<10 is true. 1<5 is also true.True != True should be false . Then why the the output is True ???

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Rupam098
  • 33
  • 5
  • 3
    Does this answer your question? [Inequalities and Parenthesis in Python](https://stackoverflow.com/questions/33948574) & [What is the operator precedence when writing a double inequality](https://stackoverflow.com/questions/12658197) – Trenton McKinney Oct 10 '20 at 05:09
  • 1
    @Trenton McKinney yes.. Thanks for sharing.. – Rupam098 Oct 10 '20 at 05:17

1 Answers1

3

Because of operations priorities meaning of your expression is different. You need to put parentheses: (0 < 10) != (1 < 5), to have what you want.

Otherwise your original expression means same as (0 < 10) and (10 != 1) and (1 < 5) which is not what you expected. (thanks to @TomKarzes)

Arty
  • 14,883
  • 6
  • 36
  • 69