【leetcode❤python】 125. Valid Palindrome

#-*- coding: UTF-8 -*-
class Solution(object):
    def isPalindrome(self, s):
        """
        :type s: str
        :rtype: bool
        """
        s=s.lower()
        if s==None:return False
        isPalindrome1=[]
        isPalindrome2=[]
        
        for c in s:
            if (c>='a' and c<='z') or (c>='0' and c<='9'):
                isPalindrome1.append(c)
        for i in range(len(s))[::-1]:
            if (s[i]>='a' and s[i]<='z') or (s[i]>='0' and s[i]<='9'):
                isPalindrome2.append(s[i])
        
        return isPalindrome2==isPalindrome1
        
sol=Solution()
print sol.isPalindrome("ab")


posted @ 2016-11-13 19:28  火金队长  阅读(170)  评论(0编辑  收藏  举报