def is_palindrome(n): i = 0 while i < len(str(n)) - i - 1: if str(n)[i] != str(n)[len(str(n)) - i - 1]: return False else: i += 1 return True
output = filter(is_palindrome,range(1,2000)) print(list(output))
Sign in to make a reply
不想饿肚子不想太平凡
-- coding: utf-8 --
def is_palindrome(n): i = 0 while i < len(str(n)) - i - 1: if str(n)[i] != str(n)[len(str(n)) - i - 1]: return False else: i += 1 return True
output = filter(is_palindrome,range(1,2000)) print(list(output))