Discuss / Python / 字符串反转不会,用了笨方法

字符串反转不会,用了笨方法

Topic source

东东男装

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-
def is_palindrome(n):
    m = '%d'%n
    L = list(m)
    i = 0
    while i < (len(L)-i):
        if L[i] == L[len(L)-(i+1)]:
            i = i + 1 
        else:
            return False
            break
        return True



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

  • 1

Reply