Can somebody tell me why is my code getting rejected over and over again?

Hey Everyone,
I am new on CodeChef. I am solving PALIN Problem - CodeChef but my code is getting rejected again and again. I am solving this problem using Python.
My code is giving correct output on the system but CodeChef is not accepting my solution.

Here’s my solution : CodeChef: Practical coding for everyone

Try to optimize your code , it is giving TLE as the constraints of k are (1000000 digits)
are big.