def is_reverse(number):
reverse = 0
while number > 0:
remainder = number % 10
reverse = reverse * 10 + remainder
number = number // 10
#print(reverse)
return reverse
def ages():
number = 12
while number < 100:
x = number - is_reverse(number)
if number > is_reverse(number) and 20 > x > 12:
print(number)
#break
number = number + 1
ages()
答案 0 :(得分:0)
只需创建一个列表,附加结果并返回该列表
def is_reverse(number):
reverse = 0
while number > 0:
remainder = number % 10
reverse = reverse * 10 + remainder
number = number // 10
#print(reverse)
return reverse
def ages():
number = 12
li = []
while number < 100:
x = number - is_reverse(number)
if number > is_reverse(number) and 20 > x > 12:
li.append(number)
#break
number = number + 1
return li
print ages()