Skip to content

Instantly share code, notes, and snippets.

@ZhouYang1993
Created October 13, 2020 22:22
8 Levels of Using List Comprehension in Python
a = 1
b = 2 if a>0 # SyntaxError: invalid syntax
b = 2 if a > 0 else -1
# b==2,ternary conditional operator works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment