Is it okay to check the odd / even length of the palindrome number / line? Most of the snippets I came across do not do this basic test. If the length is even, it can't be a palindrome, no?
if len(var) % 2 != 0: # could be a palindrome, continue... else: break
Or is it better (for example, faster) to start a direct comparison of the first and last numbers / letters?
Edit : Well, stupid question, had to think twice! :)
source share