[Python]filter-获取回数

2016-08-21  本文已影响48人  PlutoMa
def is_palindrome(n):
    theStr = str(n)
    theStr2 = ''
    for char in theStr:
        theStr2 = char + theStr2
    if theStr2 == theStr:
        return True
    else:
        return False

print filter(is_palindrome, range(1, 1000))
上一篇 下一篇

猜你喜欢

热点阅读