Nested if-else Statement in Python