1. 程式人生 > >【Python學習日記】判斷是不是迴文數 filter

【Python學習日記】判斷是不是迴文數 filter

大神答案:

def is_palindrome(n):
    n=str(n)
    m=n[::-1]
    return n==m



我的答案:

    tmp_str = str(n)
    i = len(tmp_str) - 1
    j = 0
    while i > j :
      if tmp_str[i] == tmp_str[j] :
        i = i - 1 
        j = j + 1
        pass
      else : 
        return False
    return True