2020-04
14
一句秒杀一段话
还记得初中的时候数学老师跟我说初等数学比高等数学难多了,幸好,我这辈子暂时只学过高等数学,而且几乎都还给大学老师了……
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # def first(word): # return word[0] # def last(word): # return word[-1] # def middle(word): # return word[1:-1] # def is_palindrome(word): # if len(word) <= 1: # return True # elif first(word) != last(word): # return False # else: # return is_palindrome(middle(word)) def is_palindrome(word): return word[::-1] == word word = input('word is ') print(is_palindrome(word)) # word is qwerreq # False # word is poiuuiop # True |
还没有评论