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