Write a function in Python to check if a number is a palindr…

# Function to check if a string is palindrome

def is_palindrome(s):

# Remove spaces and convert to lowercase for uniformity

s = s.replace(” “, “”).lower()

# Compare string with its reverse

return s == s[::-1]

# Test the function

word = “Madam”

if is_palindrome(word):

print(f’”{word}” is a palindrome ‘)

else:

print(f’”{word}” is not a palindrome ‘)

WRITE MY PAPER


Comments

Leave a Reply