Created
December 16, 2017 16:45
-
-
Save charlesreid1/9e0e75fb5b293a799142f4da58c333fa to your computer and use it in GitHub Desktop.
Conditional list construction with booleans in Python
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
doit = True | |
dontdoit = False | |
print( doit*[1,2,3] + [4,5,6] + dontdoit*[7,8,9]) | |
# prints [1, 2, 3, 4, 5, 6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment