I have the following function:
def InRange(number):
return 5 <= number >= 1
I want this to say false if the number is not within
Use this:
1 <= number <= 5
From docs:
x < y <= zis equivalent tox < yandy <= z, except thatyis evaluated only once (but in both caseszis not evaluated at all whenx < yis found to be false).
Your (incorrect)expression is actually equivalent to:
number >=5 and number >= 1
So, it is going to be True for any number between 1 to infinity: