Possible Duplicate:
Conditional operator in Python?
Is there a c-like operator in python that check if a condition holds and assign a value accordingly?
<condition> ? <operation> : <operation>
The syntax is different in Python.
<operation> if <condition> else <operation>
For example,
x = max(y, z)
is roughly the same as:
x = z if z > y else y
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With