Jan-06-2020, 03:09 AM
Oh, sorry. You need to actually call the check_range function to start the whole thing. And 'number' on line 21 should be 'n' (or 'n' on line 20 should be 'number').
As long as _num_ranges is not empty, num_range will be defined when it gets to line 27. The loop variable num_range is what you are checking with in_range(). If it's valid, the loop breaks, and then what you return is the valid range.
However, come to think of it, there is the possibility that a valid range is not found. In that case, find_range will return the last range, even if it's not valid (because that will be the value after the loop is done). You could fix that with an else:
As long as _num_ranges is not empty, num_range will be defined when it gets to line 27. The loop variable num_range is what you are checking with in_range(). If it's valid, the loop breaks, and then what you return is the valid range.
However, come to think of it, there is the possibility that a valid range is not found. In that case, find_range will return the last range, even if it's not valid (because that will be the value after the loop is done). You could fix that with an else:
def find_range(n): for num_range in _number_ranges.values(): if in_range(n, num_range): return num_range else: return NoneReturning it within the loop might shut up that warning message you are getting.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures