結果 : how to avoid nested if statements python