[Solved] Why x = 7 < 5 ; print(x) gives false in python? [closed]


You seem to have mixed up the direction of the inequality operators.

When Python sees x = 7 < 5, it finds the truth value of the inequality 7 < 5 and assigns it to x. 7is not less than 5, so the statement 7 < 5 is False. So Python says x = False.

The reverse is true of x = 7 > 5. 7 is greater than 5, so 7 > 5 is True and x = True.

Remember the alligator method: < and > are like a hungry alligator looking for the most food it can eat, so it will point toward the larger value and away from the smaller.

1

solved Why x = 7 < 5 ; print(x) gives false in python? [closed]