Created
November 15, 2018 15:21
-
-
Save arzon94/f780ea16c0a77584668019b1d91dd461 to your computer and use it in GitHub Desktop.
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
| # Different ways to test multiple | |
| # flags at once in Python | |
| x, y, z = 0, 1, 0 | |
| if x == 1 or y == 1 or z == 1: | |
| print('passed') | |
| if 1 in (x, y, z): | |
| print('passed') | |
| # These only test for truthiness: | |
| if x or y or z: | |
| print('passed') | |
| if any((x, y, z)): | |
| print('passed') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment