Hackerss.com

hackerss
hackerss

Posted on

Python Check if a string is palindrome


def is_palindrome(s):
    if len(s) <= 1:
        return True
    else:
        return s[0] == s[-1] and is_palindrome(s[1:-1])

print(is_palindrome('racecar'))
print(is_palindrome('hello'))
Enter fullscreen mode Exit fullscreen mode

Latest comments (0)