This gives both things as false, what have i done wrong?

Write your in_range function here:

def in_range(num, lower, upper):
if (num == range(lower, upper)):
return True
return False

Uncomment these function calls to test your in_range function:

print(in_range(10, 10, 10))

should print True

print(in_range(5, 10, 20))

should print False

To preserve code formatting in forum posts, see: [How to] Format code in posts

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.

range will create an immutable sequence of numbers.
num is a number.

if (num == range(lower, upper)):

A number is not equal to a sequence of numbers, so the if condition will evaluate to False

Try to figure out a condition which will meet the specifications of the challenge.

I think the issue is that you are creating a sequence of numbers in the range() function and you can’t compare one value to this because it will always return false because it would not match your num parameter which is only one value.

range(5, 8) = range(5,8)
list(range(5, 8)) = [5, 6, 7]

If you are trying to compare num to see if it is equal either lower or upper, you could use an “or” statement in your function which can check if one of the conditions are met. You would just have to set the conditional statement twice like this:

if (x==a) or (x==b): # paranthesis there for clarity
return True
return False