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.
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
else:
return False