如何在Python中检查其他条件 - python

对于holiday_type,我有三个不同的答案

holiday_type = Approved
holiday_type = Confirmed
holiday_type = both

Python代码:

 result = ['confirm','validate'] if holiday_type == 'both' else ['confirm'] if holiday_type == 'Confirmed' else ['validate']

结果:

['validate']                // Approved
['confirm']                 // Confirmed
['confirm', 'validate']     // both

我不明白如何编译此if else语句:哪一个先哪一秒。您能否解释一下如何编译此条件流。

python大神给出的解决方案

不要这样可读性很重要。

if holiday_type == 'both':
    result = ['confirm','validate']
elif  holiday_type == 'Confirmed':
    result = ['confirm']
else:
    result = ['validate']