Apr-04-2019, 02:13 AM
I think it's generally best to use the first version and explicitly return False. It's often useful to return True, False, or None, with None representing a situation where the truth value could not be determined for some reason. Explicitly return False makes your True/False functions consistent with that usage.
However, I often use a third case: just return condition. If the condition has a boolean operator, just return it:
However, I often use a third case: just return condition. If the condition has a boolean operator, just return it:
def five_or_less(x): return x <= 5But perhaps you were only concerned with conditions without a boolean operator.
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