Using Nested If Function Python Code