def isPalindrome(s):
'''
验证回文串很简单 双指针
但是字符串查找回文串比较难
'''
strs = ''
if s =='': ###定义空字符是回文串
return True
for i in s:
if i.isdigit():
strs += i
if i.isalpha():
strs += i.lower()
else:
continue
print(strs)
n = len(strs)
l,r = 0,n-1
while l <= r:
if strs[l] == strs[r]:
l += 1
r -= 1
else:
return False
return True
s = "A man, a plan, a canal: Panama"
isPalindrome(s)