[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))