Understanding Nested If Statements In Python