5 ms·
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)
by ngkabra 15y ago
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
- jerfelix 15y agoCreative 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() ()