步骤
- 用Python中的list方法使字符串 列表化
- 用list中的reverse方法对其 翻转
- 判断翻转之后的 和 翻转之前两个list是否相同
- 相同为True,否则为FALSE
class Solution: def judge(self , str ): # write code here chars = list(str) chars.reverse() charsRev = chars.copy() chars.reverse() if chars == charsRev: return True return False
```