Python Patterns Using Nested If