Arshad Mehmood

Search the blog

    Check if a string is a palindrome

    python1 min read

    Compare a Python string with its reversed slice to check whether it is a palindrome.

    Slicing is the way to go.

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