Created
November 1, 2017 18:11
-
-
Save pykong/42c7c311516d0302bb8537a8d0588dd5 to your computer and use it in GitHub Desktop.
In Python, not only is 0 False and 1 True, but True is 1 and False is 0. This means you can do weird things like:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> a = 1 | |
>>> (a==1) + (a>0) + (a==2) | |
2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment