给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。输入: "A man, a plan, a canal: Panama" 输出: true
def isPalindrome(s):
s1=''
for i in s:
if (ord(i)>=48 and ord(i)<=57) or (ord(i)>=65 and ord(i)<=90) or (ord(i)>=97 and ord(i)<=122):
s1+=i.lower()
s2=''.join(list(reversed(s1)))
if s1==s2:
return True
else:
return False