Don't understand why I got a challenge wrong

I was working on the Python Code Challenges: Control Flow (Advanced) and the first question states:

Create a function named in_range() that has three parameters named num, lower, and upper.

The function should return True if num is greater than or equal to lower and less than or equal to upper. Otherwise, return False.

I wrote the following code:

def in_range(num, lower, upper):
if lower <= num >= upper:
return True
else:
return False

The tests were:
print(in_range(10, 10, 10))

should print True

print(in_range(5, 10, 20))

should print False

The system showed me the first test is True and the second is False, which is correct, yet the system said:

in_range(5, 0, 10) should have returned True , and it returned False

and the code solution was as follows:
def in_range(num, lower, upper):
if(num >= lower and num <= upper):
return True
return False

Why is my code not correct when I got the same output as the solution code?

Your code

if lower <= num >= upper:

which basically mean lower <= num and num >= upper. The condition can never be fullfilled unless lower == num == upper.
Change your code to

if lower <= num <= upper:

then it should work neglecting the indentation spaces

3 Likes