#-*- coding: UTF-8 -*-
class Solution(object):
def isPalindrome(self, s):
"""
:type s: str
:rtype: bool
"""
s=s.lower()
if s==None:return False
isPalindrome1=[]
isPalindrome2=[]
for c in s:
if (c>='a' and c<='z') or (c>='0' and c<='9'):
isPalindrome1.append(c)
for i in range(len(s))[::-1]:
if (s[i]>='a' and s[i]<='z') or (s[i]>='0' and s[i]<='9'):
isPalindrome2.append(s[i])
return isPalindrome2==isPalindrome1
sol=Solution()
print sol.isPalindrome("ab")
相关文章
- Valid Palindrome leetcode java
- 【LeetCode】921. Minimum Add to Make Parentheses Valid 解题报告(Python & C++)
- Python 解LeetCode:367. Valid Perfect Square
- [Leetcode][Python]36: Valid Sudoku
- leetcode_question_125 Valid Palindrome
- 【LeetCode】125. Valid Palindrome
- 【LeetCode OJ】Valid Palindrome
- [leetcode]_Valid Palindrome
- LeetCode专题-Python实现之第9题:Palindrome Number
- [LeetCode][Python]Palindrome Number