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))
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))
本文标题:[Python]filter-获取回数
本文链接:https://www.haomeiwen.com/subject/xttwsttx.html
网友评论