Discuss / Python / 验证可用,又不如大家的简洁

验证可用,又不如大家的简洁

Topic source

L = []

def palindrome(n): L = str(n) s = 0 tag = True while s < (len(L)/2): if L[s] == L[-s-1]: tag = True and tag else: tag = False and tag s = s + 1 return tag

output = filter(palindrome, range(1,1000)) print (list(output))

结果不对,含有100, 101, 102, 103, 104...

抱歉看错代码了


  • 1

Reply