Ternary Search Code In Python