125.Valid Palindrome

 

 

class Solution:
    def isPalindrome(self, s: str) -> bool:
        s1 = s.split()
        s_tmp = ""
        for i in range(len(s1)):
            for j in range(len(s1[i])):
                if 'a'<= s1[i][j] <= 'z' or 'A'<=s1[i][j]<='Z' or '0'<=s1[i][j]<='9':
                    s_tmp += s1[i][j]
        s1 = s_tmp.lower()
        s2 = s1[::-1]
        return s1==s2

 

posted @ 2020-05-09 14:41  星海寻梦233  阅读(78)  评论(0编辑  收藏  举报