Ad
  • Custom User Avatar

    To be honest, because I wanted to have a function that only returns ints, but I understand if someone would want to return False instead, or just leave out a return for a None, which is also false-y. Therefore, this requirement.

  • Custom User Avatar

    "truthy" and "falsy" are not a slang, it's more of a terminology used in languages where some non-boolean values can be implicitly coerced to a logical value of true or false.

    For example, in Java there's no such thing, because only boolean expressions can have logical value, so you cannot write, for example, if(number % 2), you need to explicitly write if(number % 2 != 0). In many languages though some expressions yield a non-boolean value, but it can be implicitly converted to such. For example in Python, empty list, zero, or None are converted to False when used as a logical value, thus they are "falsy". Non-empty list, or numbers other than 0, can be implicitly coverted to True, therefore they are "truthy" values.

    That being said, the requirement of returnin anything as long as it's falsy is kinda poor one and looks like (much too) literal translation of some code golfing task. In Python, you have explicit False, so why the requirement of "return anything as long as it's falsy"?