Discuss / Python / 把整形转换为字符串操作结果还是很完美的

把整形转换为字符串操作结果还是很完美的

Topic source

惟莉V雅爱

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

def is_palindrome(n): l1 = [str(s) for s in n] l2 = list(filter(judge, l1)) l3 = [int(s) for s in l2] return l3

def judge(n): return n[0:] == n[::-1]

print(is_palindrome([123,243,232,4567654,3553,98766789,21312421]))


  • 1

Reply