Discuss / Python / 通过下标对比确定该整数是否为回文数

通过下标对比确定该整数是否为回文数

Topic source

陈妍素姬

#1 Created at ... [Delete] [Delete and Lock User]

# -*- coding: utf-8 -*-

def is_palindrome(s):

    m = str(s)

    n = len(m)//2

    for x in range(n):

        if m[x] != m[-x-1]:

            return False

    return True


  • 1

Reply