Python Patterns Using Nested Ifs