[🐍PyTricks]: Different ways to test multiple flags at once in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

[🐍PyTricks]: Different ways to test multiple flags at once in Python

# 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')

8th Mar 2018, 6:25 AM
Maninder $ingh
Maninder $ingh - avatar
1 Answer
+ 3
Thxx
8th Jun 2018, 2:57 PM
Sakaar Sen
Sakaar Sen - avatar