Discuss / Python / 我这个方法比较笨,只能用到这道题,如果有四位数,就不能用了

我这个方法比较笨,只能用到这道题,如果有四位数,就不能用了

Topic source

帛子先生

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

def is_palindrome(n): if len(str(n))==1: return True elif len(str(n)) == 2: return str(n)[0:1]==str(n)[1:0] else: return str(n)[0:1]==str(n)[-1:]


  • 1

Reply