Python判断字符串是否是回文的代码

def is_palindrome(s):  
    # 将字符串转换为小写并去除空格  
    s = s.lower().replace(" ", "")  
    # 反转字符串  
    s = s[::-1]  
    # 判断是否为回文字符串  
    return s == s[::-1]
s = "abcdefedcba"
is_palindrome(s)