码迷,mamicode.com
首页 > 编程语言 > 详细

【Python】回文

时间:2016-12-27 14:15:25      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:class   lin   python   div   and   span   回文   color   name   

首先判断一个字符串是否回文:

 1 def isPlalind(s):
 2     if len(s) == 1:
 3         return True
 4     else:
 5         return s[0] == s[-1] and isPlalind(s[1:-1])
 6 
 7 if __name__ == __main__:
 8     while(True):
 9         x = input(enter your string:)
10         print(isPlalind(x))

 

【Python】回文

标签:class   lin   python   div   and   span   回文   color   name   

原文地址:http://www.cnblogs.com/fcyworld/p/6225427.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!