mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
improved demo of if
expression
This commit is contained in:
parent
59c7f495c8
commit
c39746b0bb
@ -186,7 +186,7 @@ some_unknown_var # Raises a NameError
|
||||
|
||||
# if can be used as an expression
|
||||
# Equivalent of C's '?:' ternary operator
|
||||
"yahoo!" if 3 > 2 else 2 # => "yahoo!"
|
||||
"yay!" if 0 > 1 else "nay!" # => "nay!"
|
||||
|
||||
# Lists store sequences
|
||||
li = []
|
||||
|
Loading…
Reference in New Issue
Block a user