In python, if I use a ternary operator:
x = a if <condition> else b
Is a executed even if condition is false? Or does condition evaluate first and then goes to either a or b depending on the result?
The condition is evaluated first, if it is False, a is not evaluated: documentation.
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