Most efficient palindrome program for python -


this question has answer here:

very new programming , trying solve few project euler problems. know python code identifies palindrome , non-palindrome. efficient way this? please show code find efficient problem.

you can checking if string input equal reversed (that's palindrome is).

def check_palindrome(s):     return s == s[::-1] 

[::-1] reverses string because -1 tells how many steps go , negative go through string in reverse.

if need check if integers palindromes, can do:

def check_palindrome(s):     return str(s) == str(s)[::-1] 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -