built-in function to check the length of a string.

Write a function called palindrome that takes a string argument and returns True if it is a palindrome and False otherwise. Remember that you can use the built-in function len( ) to check the length of a string.

answer:


Here’s a Python function called `is_palindrome` that checks if a string is a palindrome:

“`python

def is_palindrome(string):

# Convert string to lowercase to handle case-insensitive palindromes

string = string.lower()

# Remove non-alphanumeric characters from the string

string = ”.join(char for char in string if char.isalnum())

# Compare the string with its reverse

return string == string[::-1]

# Example usage:

print(is_palindrome(“racecar”)) # Output: True

print(is_palindrome(“hello”)) # Output: False

“`

This function converts the input string to lowercase, removes non-alphanumeric characters, and then compares the string with its reverse to determine if it’s a palindrome.