Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

At 12 characters, this is definitely not the shortest, but it is a totally different approach than the other solutions:

    >>> f = lambda: g()if 0 else(1)
    >>> f()
    1


Creative solution! You can knock it down a character by removing the "1" and simply returning an empty tuple.

    >>> f = lambda: g()if 0 else()
    >>> f()
    ()




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: