with a simple filter that test input against a range 0-100.
def foo(foo_input):
if 0 <= foo_input <= 100:
return f_input
I sort of like the implicit return None
but pylint flags it as bad style, warning:
Either all return statements in a function should return an expression, or none of them should.pylint(inconsistent-return-statements)
Hence,
def foo(foo_input):
if 0 <= foo_input <= 100:
return f_input
return None
might be better style, even if they are functionally the same.
More info available here, where the Pylint change-log states:
A new Python checker was added to warn about inconsistent-return-statements. A function or a method has inconsistent return statements if it returns both explicit and implicit values ...
According to PEP8, if any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable).