Python 判断回文数并输出指定范围内的所有回文数
def Ishuiwen(x): ' 将x转化为字符串,并反转 ' x = str(x)[::-1] ' 将反转后的字符串与原字符串比较 ' if str(x) == str(x)[::-1]: return True else: return False
a, b = map(int, input().split()) ans = set() for i in range(a, b+1): if Ishuiwen(i): ans.add(i) for i in ans: print(i)
原文地址: https://www.cveoy.top/t/topic/n7CA 著作权归作者所有。请勿转载和采集!