jeudi 9 avril 2015

How to interpreter single line if else if else condition in Python

I have three different answer 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.


Aucun commentaire:

Enregistrer un commentaire