Python Use Variable In Nested If Else Condition