I have three different answers for holiday_type
holiday_type = Approved
holiday_type = Confirmed
holiday_type = both
Python Code:
result = ['confirm','validate'] if holiday_type == 'both' else ['confirm'] if holiday_type == 'Confirmed' else ['validate']
Result:
['validate'] // Approved
['confirm'] // Confirmed
['confirm', 'validate'] // both
I can't understand how to compile this if else statement: which one first which one second. Can you please explain how to compile this condition flow.
result = ['confirm','validate'] if holiday_type == 'both' else (['confirm'] if holiday_type == 'Confirmed' else ['validate'])- you can easily see two nested similar statements oftrue_val if condition else false_valform.true_expr if condition else false_exprisconditionand then one oftrue_exprorfalse_expris evaluated, as necessary.