Python Patterns Using Nested If Statements