Discuss / Python / [练习]

[练习]

Topic source

def is_palindrome(n):

list = []
temp = n
while temp > 0:
    list.append(temp % 10)
    temp = temp // 10
l = len(list) // 2
c = 0
while c < l:
    if list[c] == list[-(c+1)]:
        c = c + 1
    else:
        break
return c >= l

output = filter(is_palindrome, range(1, 1000)) print(list(output))


  • 1

Reply