discussion

Arnaud Delobelle arnodel at gmail.com
Fri Oct 1 08:28:28 CEST 2010


John Nagle <nagle at animats.com> writes:

> On 9/30/2010 7:12 PM, Geo_subodh wrote:
>> please send me the simple python code that uses input number greater
>> than3 digits(>3 digits) and  checks whether the number is palindrome
>> or not.
>
> def ispalin(s) :
>     s = str(s)
>     n = len(s) / 2
>     return(s[:n] == s[::-1][:n])

      return  s.startswith(s[n:][::-1])

You'll save valuable time when deploying your palindrome checking system
and it has to check trillions of palindromes an hour :)

-- 
Arnaud



More information about the Python-list mailing list