字符串算法---判断回文

1
2
3
4
5
6
7
8
9
10
11
12
13
def isHw(a):  
i, j = 0, len(a)-1
while i <= j:
if a[i] != a[j]:
return False
i += 1
j -= 1

return True
if __name__ == "__main__":
print(isHw('abcdedcba'))
print(isHw('abcdedcb'))
print(isHw('abcdeedcba'))