Discuss / Python / 6666,超简单的两种解法

6666,超简单的两种解法

Topic source

return str(n) == str(n)[::-1]#最简单

from functools import reduce#巧妙的

def is_palindrome(n): return reduce(lambda x,y:y+x,str(n))==str(n)


  • 1

Reply