用python打印出所有10000以内的回文数
#回文数,利用字符串反转,判断反转前后是否相等 count = 0 array = [] for num in range(0,10000): if str(num) == str(num)[::-1]: print(num) if num not in array: array.append(num) count += 1 print("共有%d个5位回文数" %(count)) print("所有回文数组成的数组为 " + array)
2023-09-28 17:09:40
用python打印出所有10000以内的回文数
#回文数,利用字符串反转,判断反转前后是否相等 count = 0 array = [] for num in range(0,10000): if str(num) == str(num)[::-1]: print(num) if num not in array: array.append(num) count += 1 print("共有%d个5位回文数" %(count)) print("所有回文数组成的数组为 " + array)