判断输入的是否为回文

2015-10-12 0 946
判断输入的是否为回文
def isPalindrome(s):
	def toChars(s):
		s = s.lower()
		ans = ''
		for c in s:
			if c in 'abcdefghijklmnopqrstuvwxyz':
				ans = ans + c
		return ans
	def isPal(s):
		if len(s)<=1:
			return True
		else:
			return s[0]==s[-1] and isPal(s[1:-1])
	return isPal(toChars(s))

遇见资源网 python 判断输入的是否为回文 http://www.ox520.com/15858.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务