Pattern In Python Using Nested If And Or In Excel