Skip to content

Instantly share code, notes, and snippets.

@charlesreid1
Created December 16, 2017 16:45
Show Gist options
  • Save charlesreid1/9e0e75fb5b293a799142f4da58c333fa to your computer and use it in GitHub Desktop.
Save charlesreid1/9e0e75fb5b293a799142f4da58c333fa to your computer and use it in GitHub Desktop.
Conditional list construction with booleans in Python
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