Discuss / Python / 作业

作业

Topic source

老阿_

#1 Created at ... [Delete] [Delete and Lock User]
def is_palindrome(n):
    a=str(n)
    i=0
    while i<len(a)//2:
        if a[x]!=a[-(x+1)]:
            break
        i=i+1
    if i==len(a)//2:
        return True
    else:
        return False

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

老阿_

#2 Created at ... [Delete] [Delete and Lock User]

变量没改完~~~~

def is_palindrome(n):
    a=str(n)
    i=0
    while i<len(a)//2:
        if a[i]!=a[-(i+1)]:
            break
        i=i+1
    if i==len(a)//2:
        return True
    else:
        return False

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

  • 1

Reply