Palindrome Checker

Write a Python function named is_palindrome that checks whether a passed string is a palindrome or not. A palindrome is a word, phrase, or sequence that reads the same backward as forward. Return True if it is a palindrome, False otherwise.

Example 1:

Input: is_palindrome('racecar') 
Output: True

Example 2:

Input: is_palindrome('hello') 
Output: False

To check if a string is a palindrome, compare the string with its reversed version.

def is_palindrome(word):
    return word == word[::-1]

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!