Sep-30-2018, 05:01 AM
def in1to10(n, outside_mode): if outside_mode != True: if n >= 1 and n <= 10: return True if outside_mode == True: if n <= 1 or n >= 10: return True else: return False print(in1to10(2, True))The code is supposed to meet the conditions:
Given a number n, return True if n is in the range 1..10, inclusive. Unless outside_mode is True, in which case return True if the number is less or equal to 1, or greater or equal to 10.
My code works for every case except when outside_mode=True and n is between 1 and 10, the functions returns none. Why is the function not returning False, shouldn't the else statement make the function always return false if the above two if statements are not met?