def ispalindrome(n): for a in range(0, len(n)-1): if n[a-1] == n[-a]: yield n else: pass output = filter(ispalindrome, range(1, 1000)) print(list(output))
结果输出了1-1000所有的数。。
int 哪来的len()
Sign in to make a reply
Capella想干什么呢
def ispalindrome(n): for a in range(0, len(n)-1): if n[a-1] == n[-a]: yield n else: pass output = filter(ispalindrome, range(1, 1000)) print(list(output))
结果输出了1-1000所有的数。。